页面常用代码整理

在页面不够高的时候,footer永远保持在底部的css代码


   
.main { display: flex; min-height: 100vh; flex-direction: column; } header { background: red; min-height: 100px; } content { background: blue; flex: 1; /* 1代表最大 */ } footer { background: green; min-height: 100px; }

导航栏的active的js代码

$(document).ready(function () {
    var a = document.URL;
    $(".nav ul li").each(function () {
        var b = $(this).children("a")[0].href;
        if (a == b) {
            $(this).children("a").parent().addClass("active");
        }
        else {
            $(this).children("a").parent().removeClass("active");
        }
    })
})

banner大图的自适应js代码

$(function(){
    $(".bd img").css("display","none")
    $(".bd li").each(function(e){
    $(".bd li:eq("+e+")").css("backgroundImage", "url(" + $(".bd li:eq("+e+")").find("img").attr("src") + ")");
    });
})

PC站跳转移动站

  

请将以上代码装到pc站首页文件中后面  
m文件夹直接上传至pc站空间根目录

你可能感兴趣的:(页面常用代码整理)