gpt4 book ai didi

html - 让UL只能横向扩张

转载 作者:行者123 更新时间:2023-11-28 14:23:39 26 4
gpt4 key购买 nike

我需要将 LI 元素动态添加到长度为“n”的 UL 元素。我现在拥有的 HTML 是...

<div class="center">
<ul id="tabList" class="parent">
<!-- I am adding LI using jQuery here. -->
<br class="clearfix" />
</ul>
</div>

这里应用的CSS是...

.center
{
top: 0;
margin: 0 15%;
width: 70%;
overflow: hidden;
}

.center ul.parent
{
left: 0;
height: 100%;
position: relative;
}

.center ul.parent li
{
float: left;
margin: 0 5px;
}

.center ul.parent li .tab
{
position: relative;
padding: 5px 10px;
background: transparent;
font-size: 16px;
font-weight: bold;
line-height: 49px;
border: 1px solid rgba(0, 0, 0, 0.1);
color: #A9D0F5;
background: rgba(0, 0, 0, 0.1);
border-radius: 3px;
}

我必须根据它的 child 宽度设置.parent宽度,以免让UL在这里垂直扩展。有什么方法可以用来修复宽度设置吗?我不喜欢根据 child 累积的宽度来设置宽度。

最佳答案

你想要类似 this 的东西?

为了避免新的 LI 出现故障,我投入了大量资金。

.center ul.parent
{
width: 1000%;
}

但我认为你的问题出在这里:

.center
{
width: 70%;
overflow: hidden;
}

.center 将不允许显示新的 LI

我向您推荐,因为您将使用 jQuery 添加 LI 标记,检测 .center ul.parent 的第一个宽度并在每个新 LI 添加。

根据您在评论中告诉我的内容,我制作了另一个演示,看看是否对您有帮助 --> http://jsfiddle.net/Galled/KQqYm/4/

关于html - 让UL只能横向扩张,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8247320/

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