gpt4 book ai didi

css - ul li a 不按文本大小调整 li 的大小

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

A 有这个菜单:

<li id="menu-item-32"><a href="#"><span>Dekanát</span></a>
<ul>
<li class="line"><a href="http://****.**/dekanat/farnosti/">Farnosti</a></li>
<li ><a href="http://****.**/dekanat/duchovne-spravy/">Duchovné správy</a></li>
</ul>
</li>

但是,如果在第 2 里有最长的文字,是不是这样:

(问题出在3-4第2里!)

它没有设置大小....

CSS:

div#top-menu{
height: 36px;
margin-top: 10px;
margin-bottom: 3px;
background-color: #111;
background-image: url("http://****.**/project/wp-lop/wp-content/themes/LOP/img/nav-

bg.png");
}

div#top-menu ul li{
float: left;
list-style: none;
display: block;
position: relative;
padding: 0 20px 0 20px;
border-right: 1px solid #e3d8c4;
margin-top: 0px;
height: 36px;
}
div#top-menu ul li:hover{
background-color: rgba(0,0,0,0.45);
}

div#top-menu ul li:last-child{
border-right: none;
}

div#top-menu ul li a{
text-transform: uppercase;
color: #e3d8c4;
text-decoration: none;
display: block;
font-weight: normal;
margin-top: 7px;
}
div#top-menu ul li.active a{
color: #d99d4d;
}
div#top-menu ul li a:hover{
color: #d99d4d;
}
div#top-menu ul li a span{
display: block;
}
div#top-menu ul li ul {
font-size:15px;
display: none;
position: absolute;
top: 36px;
left: 0px;
width: 200px;
line-height: 29px;
text-indent: 0px;
padding:0px 0px 0px 0px;
margin:0px;
background: #1F1B17;
/*background-image: -moz-linear-gradient(#515151, #333);
background-image: -webkit-linear-gradient(#515151, #333);
background-image: -o-linear-gradient(#515151, #333);
background-image: -ms-linear-gradient(#515151, #333);
background-image: linear-gradient(#515151, #333);*/
/*-webkit-border-radius: 2px;
border-radius: 2px;*/
z-index: 80;
}
div#top-menu ul li ul li:hover {
color: #e0a95f;
}
div#top-menu ul li ul li{
float: none;
display: block;
border-bottom: 1px solid #e3d8c4;;
border-right: none;
position: relative;
height: 29px;
margin-top: -7px;
text-transform: none;
}

如何解决? :/谢谢

最佳答案

div#top-menu ul li{
float: left;
list-style: none;
display: block;
position: relative;
padding: 5px 20px; /* you can use padding instead of giving height */
border-right: 1px solid #e3d8c4;
margin-top: 0px;
height: 36px; /* you do not need that */
}
div#top-menu ul li ul {
font-size:15px;
display: none;
position: absolute;
top: 36px;
left: 0px;
width: 200px;
/*line-height: 29px; also remove*/
text-indent: 0px;
padding: 0;
margin:0px;
background: #1F1B17;
z-index: 80;
}


div#top-menu ul li ul li{
float: none;
display: block;
border-bottom: 1px solid #e3d8c4;;
border-right: none;
position: relative;
/*height: 29px; / also remove it from here. */
margin-top: -7px;
text-transform: none;
}

我认为是因为高度

关于css - ul li a 不按文本大小调整 li 的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15131340/

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