gpt4 book ai didi

HTML 和 CSS 浏览器兼容性问题

转载 作者:行者123 更新时间:2023-11-28 13:08:01 25 4
gpt4 key购买 nike

我最初是在 Chrome 中创建我的导航,其结果完全符合我的需要。然后我发现 Mozilla Firefox 不会输出相同的结果,Member Action 和 Admin Related 下的下拉菜单将垂直显示,而不是我想要的水平显示。然而,我最大的失望是在 Internet Explorer 中测试导航,它甚至不显示下拉菜单。我非常感谢有人检查以下代码和您的反馈,谢谢。

通过更改 css 中的一行解决了问题

导航 ul li {float: left;列表样式:无;

HTML

<div id="navigationContainer"> 
<div id="navigation">
<ul>
<li class="borderleft"><a href="homepage.jsp">Home</a> </li>
<li><a href="Registration.jsp">Register</a> </li>
<li><a href="searchCar.jsp">Search cars</a></li>
<li><a href="DisplayAll.jsp">Display all cars</a></li>
<li><a href="#">Member Actions</a>
<ul> <!-- Open drop down menu -->
<li class="bordertop"><a href="Login.jsp">Login</a></li>
<li class="floatLeft"><a href="Member.jsp">Member Area</a></li>
<li><a href="ReserveCar.jsp">Reservation</a></li>

<li><a href="ContactUs.jsp">Contact us</a></li>
<li><a href="#">Admin Related</a>
<ul>
<li class="bordertop"><a href="braking.html">Insert new car</a></li>
<li><a href="weather.html">Delete a car</a></li>
</ul>
</li>
</ul>
</div>
</div>

</BODY>
</HTML>

CSS

* {padding: 0%; margin 0%; } /* Overwrites the browser stylesheet */



#navigationContainer {background:url(images/navi.png); width:100%;position: relative; white-space:nowrap; word-spacing:0; }

#navigation {width:1200px; height:65px; position: relative; font-family: Arial; margin: 2px auto; font-size: 125%; }

#navigation ul { list-style-type: none; }

#navigation ul li {float: left; position: relative; }

#navigation ul li a { border-right: 2px solid #e9e9e9; padding: 20px;
display: block; margin: 0 auto; text-align: center; color: black; text-decoration: none; }

#navigation ul li a:hover { background: blue; color: white; }

#navigation ul li ul { display: none; }

#navigation ul li:hover ul {display: block; position: absolute; }

#navigation ul li ul li {float:left; position:relative; }

#navigation ul li:hover ul li a { background: #12aeef; color: white; position:relative; margin: 0px auto; border-bottom: 1px solid white; border-right: 1px solid white; width: 119px; }

#navigation ul li:hover ul li a:hover { background: blue;}

.bordertop { border-top: 1px solid white; }
.borderleft { border-left: 2px solid #e9e9e9;}

最佳答案

试试这个 http://jsfiddle.net/Vf3AJ/

示例来自:http://www.cssnewbie.com/example/css-dropdown-menu/horizontal.html

已编辑将水平误读为垂直。在 IE10、FF 和 Chrome 中测试

附带说明:水平菜单存在严重问题,具体取决于查看器屏幕的宽度。

CSS

nav {
position: absolute;
top: 0;
right: 0;
margin: 0;
padding: 0;
}
nav li {
list-style: none;
float: left;
}
nav li a {
display: block;
padding: 3px 8px;
text-transform: uppercase;
text-decoration: none;
color: #999;
font-weight: bold;
}
nav li a:hover {
background: blue;
color: white;
}
nav li ul {
display: none;
}
nav li:hover ul, nav li.hover ul {
position: absolute;
display: inline;
left: 0;
width: 100%;
margin: 0;
padding: 0;
}
nav li:hover li, nav li.hover li {
float: left;
}
nav li:hover li a, navbar li.hover li a {
color: #000;
}
nav li li a:hover {
color: white;
}

HTML

<div id="navigationContainer">
<nav id="navigation">
<ul>
<li class="borderleft"><a href="homepage.jsp">Home</a>
</li>
<li><a href="Registration.jsp">Register</a>
</li>
<li><a href="searchCar.jsp">Search cars</a>

</li>
<li><a href="DisplayAll.jsp">Display all cars</a>

</li>
<li><a href="#">Member Actions</a>

<ul>
<!-- Open drop down menu -->
<li class="bordertop"><a href="Login.jsp">Login</a>

</li>
<!-- A bordertop class is given to this listed element in order to style a top border for in in the external CSS file. -->
<li class="floatLeft"><a href="Member.jsp">Member Area</a>

</li>
<li><a href="ReserveCar.jsp">Reservation</a>

</li>
</ul>
</li>
<li><a href="ContactUs.jsp">Contact us</a>

</li>
<li><a href="#">Admin Related</a>

<ul>
<li class="bordertop"><a href="braking.html">Insert new car</a>

</li>
<li><a href="weather.html">Delete a car</a>

</li>
</ul>
</li>
</ul>
</nav>
</div>

关于HTML 和 CSS 浏览器兼容性问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15744906/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com