gpt4 book ai didi

CSS 下拉列表在 chrome 中不起作用

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

我在 IE7 中使用此 css 代码,它运行良好,没有任何问题。现在在 IE11 和 chrome 中,下拉菜单不起作用,我看到主菜单和所有子菜单在一起。在这方面需要帮助以了解可以采取哪些措施来修复它。谢谢。

<div id='cssmenu'> 
<ul>
<li class='active'><a href='url'><span>text</span></a></li>
<li class='has-sub'><a href='#'><span>text</span></a></li>
<ul>
<li><a href='url'><span>text</span></a></li>
<li><a href='url'><span>text</span></a></li>
</ul>
body {
background: #4096EE url(images2/img1.jpg) repeat-x;
text-align: justify;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: small;
color: #333333;
}

h1 {
}

h2, h3 {
margin-top: 0px;
}

h4, h5, h6 {
}

p, ol, ul, dl, blockquote {
}

a {
color: #1B4978;
}

a:hover {
text-decoration: none;
}

/* Header */

#header {
width: 600px;
height: 60px;
margin: 0px auto;
}

#header h1 {
float: left;
margin: 0px;
padding-top: 20px;
font-size: 42px;
letter-spacing: -2px;
}

#header h2 {
float: right;
margin: 10px 0px 0px 0px;
padding-top: 28px;
font-size: 16px;
letter-spacing: -1px;
color: #FFFFFF;
}

#header a {
text-decoration: none;
color: #FFFFFF;
}

/* Menu */

#menu {
width: 600px;
height: 30px;
margin: 0px auto;
}

#menu ul {
margin: 0px;
padding: 0px;
list-style: none;
}

#menu li {
display: inline;
}

#menu a {
display: block;
float: left;
width: 120px;
padding: 5px 0px;
text-align: center;
text-decoration: none;
font-weight: bold;
background: #EEEEEE;
}

#menu a:hover {
background: #CCCCCC;
}

/* Content */

#content {
background: #FFFFFF;
width: 600px;
margin: 0px auto;
padding: 2px 0px 0px 0px;
}

#colOne {
float: right;
width: 360px;
margin-top: 20px;
padding-right: 20px;
}

#colTwo {
float: left;
width: 180px;
margin-top: 20px;
padding-right: 20px;
padding-left: 20px;
}

#colTwo ul {
margin-left: 0px;
padding-left: 0px;
list-style-position: inside;
}

#content h1 {
background-color: #B2D4F7;
padding: 5px 0px 5px 5px;
color: #173E68;
}

#content h2 {
background-color: #B2D4F7;
padding: 5px 0px 5px 5px;
text-transform: uppercase;
font-size: 16px;
color: #173E68;
}

#content h3 {
color: #2F73B8;
}
/* Footer */

#footer {
width: 600px;
margin: 0px auto;
padding: 3px 0px 0px 0px;
height: 50px;
background: #EEEEEE;
}

#footer p {
margin: 0px;
padding-top: 15px;
text-align: center;
font-size: 11px;
color: #999999;
}

#footer a {
color: #666666;
}

#footer a:hover {
color: #333333;
}

#cssmenu{
border:none;
border:0px;
margin:0px auto;
padding:0px;
font: 67.5% 'Lucida Sans Unicode', 'Bitstream Vera Sans', 'Trebuchet Unicode MS', 'Lucida Grande', Verdana, Helvetica, sans-serif;
width:600px;
font-size:14px;
font-weight:bold;
}
#cssmenu ul{
background:#333333;
height:35px;
list-style:none;
margin:0;
padding:0;
}
#cssmenu li{
float:left;
padding:0px;
}
#cssmenu li a{
background:#333333 url('seperator.gif') bottom right no-repeat;
color:#cccccc;
display:block;
font-weight:normal;
line-height:35px;
margin:0px;
padding:0px 25px;
text-align:center;
text-decoration:none;
}
#cssmenu li a:hover, #cssmenu ul li:hover a{
background: #2580a2 url('hover.gif') bottom center no-repeat;
color:#FFFFFF;
text-decoration:none;
}
#cssmenu li ul{
background:#333333;
display:none;
height:auto;
padding:0px;
margin:0px;
border:0px;
position:absolute;
width:225px;
z-index:200;
/*top:1em;
/*left:0;*/
}
#cssmenu li:hover ul{
display:block;

}
#cssmenu li li {
background:url('sub_sep.gif') bottom left no-repeat;
display:block;
float:none;
margin:0px;
padding:0px;
width:225px;
}
#cssmenu li:hover li a{
background:none;

}
#cssmenu li ul a{
display:block;
height:35px;
font-size:12px;
font-style:normal;
margin:0px;
padding:0px 10px 0px 15px;
text-align:left;
}
#cssmenu li ul a:hover, #cssmenu li ul li:hover a{
background:#2580a2 url('hover_sub.gif') center left no-repeat;
border:0px;
color:#ffffff;
text-decoration:none;
}
#cssmenu p{
clear:left;
}

最佳答案

我很惊讶 HTML 在任何地方都能按预期工作,但 IE7 是一大堆错误。

你有一个 <ul>作为另一个 child <ul> ,这不是有效的 HTML。 <ul>只能包含 <li>元素。该子菜单列表应该是 <li>child在它上面:

<li class='has-sub'><a href='#'><span>text</span></a> 
<ul>
<li><a href='url'><span>text</span></a></li>
<li><a href='url'><span>text</span></a></li>
</ul>
</li>

body {
background: #4096EE url(images2/img1.jpg) repeat-x;
text-align: justify;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: small;
color: #333333;
}

h1 {
}

h2, h3 {
margin-top: 0px;
}

h4, h5, h6 {
}

p, ol, ul, dl, blockquote {
}

a {
color: #1B4978;
}

a:hover {
text-decoration: none;
}

/* Header */

#header {
width: 600px;
height: 60px;
margin: 0px auto;
}

#header h1 {
float: left;
margin: 0px;
padding-top: 20px;
font-size: 42px;
letter-spacing: -2px;
}

#header h2 {
float: right;
margin: 10px 0px 0px 0px;
padding-top: 28px;
font-size: 16px;
letter-spacing: -1px;
color: #FFFFFF;
}

#header a {
text-decoration: none;
color: #FFFFFF;
}

/* Menu */

#menu {
width: 600px;
height: 30px;
margin: 0px auto;
}

#menu ul {
margin: 0px;
padding: 0px;
list-style: none;
}

#menu li {
display: inline;
}

#menu a {
display: block;
float: left;
width: 120px;
padding: 5px 0px;
text-align: center;
text-decoration: none;
font-weight: bold;
background: #EEEEEE;
}

#menu a:hover {
background: #CCCCCC;
}

/* Content */

#content {
background: #FFFFFF;
width: 600px;
margin: 0px auto;
padding: 2px 0px 0px 0px;
}

#colOne {
float: right;
width: 360px;
margin-top: 20px;
padding-right: 20px;
}

#colTwo {
float: left;
width: 180px;
margin-top: 20px;
padding-right: 20px;
padding-left: 20px;
}

#colTwo ul {
margin-left: 0px;
padding-left: 0px;
list-style-position: inside;
}

#content h1 {
background-color: #B2D4F7;
padding: 5px 0px 5px 5px;
color: #173E68;
}

#content h2 {
background-color: #B2D4F7;
padding: 5px 0px 5px 5px;
text-transform: uppercase;
font-size: 16px;
color: #173E68;
}

#content h3 {
color: #2F73B8;
}
/* Footer */

#footer {
width: 600px;
margin: 0px auto;
padding: 3px 0px 0px 0px;
height: 50px;
background: #EEEEEE;
}

#footer p {
margin: 0px;
padding-top: 15px;
text-align: center;
font-size: 11px;
color: #999999;
}

#footer a {
color: #666666;
}

#footer a:hover {
color: #333333;
}

#cssmenu{
border:none;
border:0px;
margin:0px auto;
padding:0px;
font: 67.5% 'Lucida Sans Unicode', 'Bitstream Vera Sans', 'Trebuchet Unicode MS', 'Lucida Grande', Verdana, Helvetica, sans-serif;
width:600px;
font-size:14px;
font-weight:bold;
}
#cssmenu ul{
background:#333333;
height:35px;
list-style:none;
margin:0;
padding:0;
}
#cssmenu li{
float:left;
padding:0px;
}
#cssmenu li a{
background:#333333 url('seperator.gif') bottom right no-repeat;
color:#cccccc;
display:block;
font-weight:normal;
line-height:35px;
margin:0px;
padding:0px 25px;
text-align:center;
text-decoration:none;
}
#cssmenu li a:hover, #cssmenu ul li:hover a{
background: #2580a2 url('hover.gif') bottom center no-repeat;
color:#FFFFFF;
text-decoration:none;
}
#cssmenu li ul{
background:#333333;
display:none;
height:auto;
padding:0px;
margin:0px;
border:0px;
position:absolute;
width:225px;
z-index:200;
/*top:1em;
/*left:0;*/
}
#cssmenu li:hover ul{
display:block;

}
#cssmenu li li {
background:url('sub_sep.gif') bottom left no-repeat;
display:block;
float:none;
margin:0px;
padding:0px;
width:225px;
}
#cssmenu li:hover li a{
background:none;

}
#cssmenu li ul a{
display:block;
height:35px;
font-size:12px;
font-style:normal;
margin:0px;
padding:0px 10px 0px 15px;
text-align:left;
}
#cssmenu li ul a:hover, #cssmenu li ul li:hover a{
background:#2580a2 url('hover_sub.gif') center left no-repeat;
border:0px;
color:#ffffff;
text-decoration:none;
}
#cssmenu p{
clear:left;
}
<div id='cssmenu'> 
<ul>
<li class='active'><a href='url'><span>text</span></a></li>
<li class='has-sub'><a href='#'><span>text</span></a>
<ul>
<li><a href='url'><span>text</span></a></li>
<li><a href='url'><span>text</span></a></li>
</ul>
</li>
</ul>
</div>

关于CSS 下拉列表在 chrome 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26598133/

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