在页面不够高的时候,footer永远保持在底部的css代码
<body class="main">
<header></header>
<content></content>
<footer></footer>
</body>
.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站跳转移动站
<script type="text/javascript">
function browserRedirect() {
var sUserAgent = navigator.userAgent.toLowerCase();
var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
var bIsMidp = sUserAgent.match(/midp/i) == "midp";
var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
var bIsAndroid = sUserAgent.match(/android/i) == "android";
var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {
window.location.href = 'm/index.html';
} else {
}
}
browserRedirect();
</script>
请将以上代码装到pc站首页文件中<head>后面
m文件夹直接上传至pc站空间根目录
网友评论