gpt4 book ai didi

css - 在 css 菜单中显示内联 block

转载 作者:太空宇宙 更新时间:2023-11-04 14:18:54 25 4
gpt4 key购买 nike

我正在尝试使用 display: inline-block 使我网站的菜单元素彼此相邻。我已经在我的 CSS 菜单的不同部分尝试过它,比如在“cssmenu li”等处,但它不起作用。有人知道如何帮助我吗?

CSS:

#cssmenu {
border: none;
border: 0px;
margin: -17px;
padding: 0px 0px 0;
font-family: "Times New Roman", Verdana, Helvetica, sans-serif;
font-size: 19px;
font-weight: none;
float: left;
width: 600;
margin-left: 300px;
z-index: 999;
position: fixed;
}
#cssmenu ul {
background: #fff;
height: 30px;
list-style: none;
margin: 0;
padding: 0;
}
#cssmenu li {
display: block;
float: left;
padding: 0px;
}
#cssmenu li a {
background: #fff url('seperator.png') bottom right no-repeat;
font-weight: normal;
line-height: 35px;
margin: 0px;
padding: 0px 25px;
text-align: center;
text-decoration: none;
}
#cssmenu > ul > li > a {
color: #000;
}
#cssmenu ul ul a {
color: #000;
}
#cssmenu li > a:hover,
#cssmenu ul li:hover > a {
background: #fff url('hover.png') bottom center no-repeat;
color: #ddd;
text-decoration: none;
}
#cssmenu li ul {
display: none;
background: #fff;
height: auto;
padding: 0px;
margin: 0px;
border: 0px;
position: absolute;
width: 225px;
z-index: 200;
/*top:1em;*/
/*left:0px;*/
}
#cssmenu li:hover ul {
display: block;
}
#cssmenu li li {
background: url('sub_sep.png') bottom left no-repeat;
float: auto;
margin: 0px;
display: block;
padding: 0px;
width: 225px;
background: #hhh url('hover_sub.png') center left no-repeat;
border: 0px;
color: #000;
}
#cssmenu li:hover li a {
background: none;
color: #000;
font: "Times New Roman", Verdana, Helvetica, sans-serif;
font-size: 15px;
text-align: center;
}
#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: #fff url('hover_sub.png') center left no-repeat;
border: 0px;
color: #000;
text-decoration: none;
}
#cssmenu p {
clear: left;
}

最佳答案

您可以使用#cssmenu li {display: inline block;} 和#cssmenu li a {padding: 0 16px;} 实现,但您的 html 是错误的。再次检查您的 ul 和 li。你需要:

<div id="cssmenu">
<ul>
<li class="has-sub">
<a></a>
...
</li>
<li class="has-sub">
<a></a>
...
</li>
<li class="has-sub">
<a></a>
...
</li>
</ul>
</div>

关于css - 在 css 菜单中显示内联 block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20093998/

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