gpt4 book ai didi

html - 如何将父项下的下拉菜单居中?

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

我正在尝试使几乎所有宽度都与使用百分比相关,以便它更适应不同的分辨率,但我的下拉菜单有问题。下拉菜单未以父级为中心,我希望下拉菜单位于父级下方且不比父级宽。

这是我的下拉菜单的 CSS

ul.news{

display: table-cell;
padding: 0px;
list-style: ;
}

ul li.news{
float: left;
width: 100%;
text-align: center;
background:#313131;
text-decoration: none;
list-style-type: none;
}

ul li.news2{
float: left;
width: 100%;
text-align: left;
background:#313131;
text-decoration: none;
list-style-type: none;
}


ul li a.news{

display: block;
padding: 5px 10px;
color: white;
background:#313131;
text-decoration: none ;

}
ul li a.news:hover{

text-align: center;
color: white;
background:#703f70;

}
ul li ul.news{

width: 32%;
display: none ;

}
ul li.news:hover ul{

float: center;
opacity: .87;
position: absolute;
display: block; /* display the dropdown */

}

这是html

    <table border="1" width="99%" align="center" bordercolor="#181818" bgcolor="#181818">
<tr>

<td align="center" width="32%" bordercolor="#313131" bgcolor="#313131">
<font size="5" color="#5be5e5">
<b>
<ul class="news">
<li class="news">5/19/2014
</font>
<br>
<font size="3">
(Hover Over)
</font>
<br>
<ul class="news">
<li class="news2"><font size="5" color="#b266b2">-</font> <font size="5"> Added an arrow pointing down grapic by the Content Page item on the navigation bar to show it has drop-down content.</li>
<br>
<li class="news2"><font size="5" color="#b266b2">-</font> <font size="5"> Added a Credit Archive.</li>
<br>
<li class="news2"><font size="5" color="#b266b2">-</font> <font size="5"> Added more of my own grapics. Some parts of the images were grabbed from websites and credit has been given on the Info Page in the Credit Archive.</li>
<br>
<li class="news2"><font size="5" color="#b266b2">-</font> <font size="5"> Have a great time!</li>
</ul>
</li>
</font>
</td>

<td width="1%">
</td>

<td align="center" width="32%" bordercolor="#313131" bgcolor="#313131">
<font size="5" color="#5be5e5">
<b>
<ul class="news">
<li class="news">5/18/2014
</font>
<br>
<font size="3">
(Hover Over)
</font>
<br>
<ul class="news">
<li class="news2"><font size="5" color="#b266b2">-</font> <font size="5"> Replaced some of the placeholders with my own images.</li>
<br>
<li class="news2"><font size="5" color="#b266b2">-</font> <font size="5"> Edited the News Bulletin slightly.</li>
<br>
<li class="news2"><font size="5" color="#b266b2">-</font> <font size="5"> Edited Eeveeislegendary a little.</li>
</ul>
</li>
</font>
</td>

<td width="1%">
</td>

<td align="center" width="32%" bordercolor="#313131" bgcolor="#313131">
<font size="5" color="#5be5e5">
<b>
<ul class="news">
<li class="news">5/16/2014
</font>
<br>
<font size="3">
(Hover Over)
</font>
<br>
<ul class="news">
<li class="news2"><font size="5" color="#b266b2">-</font> <font size="5"> Added Images! The images you see are only placeholders and will be replaced soon.</li>
<br>
<li class="news2"><font size="5" color="#b266b2">-</font> <font size="5"> Even more colors!</li>
<br>
<li class="news2"><font size="5" color="#b266b2">-</font> <font size="5"> Added a small pointless website I made called "Eevee Is Best Legendary".</li>
<br>
<li class="news2"><font size="5" color="#b266b2">-</font> <font size="5"> Edited the navigation bar.
<br>
<li class="news2"><font size="5" color="#b266b2">-</font> <font size="5"> Changed About Page to Info Page.
<br>
<li class="news2"><font size="5" color="#b266b2">-</font> <font size="5"> Moved content from Contact Page and Archive Page to Info Page.
<br>
<li class="news2"><font size="5" color="#b266b2">-</font> <font size="5"> Edited the News Bulletin.
<br>
<li class="news2"><font size="5" color="#b266b2">-</font> <font size="5"> Edited the Random Button and the buttons for the poll.
</ul>
</li>
</font>
</td>

</tr>
</table>

这是一个活生生的例子。

http://jsfiddle.net/yU9tp/

最佳答案

首先从 td 标签中移除 align:center,这是这里的主要问题。然后根据需要调整边框和填充/等。

关于html - 如何将父项下的下拉菜单居中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23773228/

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