这个就是顶部导航,在我的电脑上显示正常,但是换别的分辨率电脑,就显示有问题了,
我这里边用了一段js代码,贴出来
$(document).ready(function(){ var topmain=$("#header").height();//是头部的高度加头部与nav导航之间的距离 var nav=$(".daohang"); $(window).scroll(function(){ if ($(window).scrolltop()>topmain){//如果滚动条顶部的距离大于topmain则就nav导航就添加类.nav_scroll,否则就移除 nav.addclass("daohang_scroll"); }else{ nav.removeclass("daohang_scroll"); } });});
页面网址 http://www.25mj.com/huodong/160227/index.php 求解决!!
<!DOCTYPE html><html><head> <title></title> <style type="text/css"> #nav{ position:relative; width: 100%; height: 50px; border: 1px solid #cccccc; } #content{ position: absolute; left: 0px; right: 0px; margin: 0px auto; width: 400px; height:40px; border: 1px solid black; } </style></head><body> <div id="nav"> <div id="content"></div> </div></body></html>
<!DOCTYPE html><html><head> <title></title> <style type="text/css"> *{ padding: 0px; margin: 0px; } #nav{ position:fixed; width: 100%; height: 45px; background-color:red; } #content{ position: absolute; left: 0px; right: 0px; margin: 0px auto; width: 810px; height:45px; } ul{ list-style-type:none; height: 100%; } li{ float: left; width: 100px; height: 100%; margin-right:1px; background-color:yellow; } </style></head><body> <div id="nav"> <div id="content"> <ul> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> </ul> </div> </div></body></html>
<!DOCTYPE html><html><head> <title></title> <style type="text/css"> *{ padding: 0px; margin: 0px; } #nav{ position:fixed; width: 100%; height: 45px; background-color:red; } #content{ position: absolute; left: 0px; right: 0px; margin: 0px auto; width: 810px; height:45px; } ul{ list-style-type:none; height: 100%; } li{ float: left; width: 100px; height: 100%; margin-right:1px; background-color:yellow; } </style></head><body> <div id="nav"> <div id="content"> <ul> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> <li></li> </ul> </div> </div></body></html>
HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号