gpt4 book ai didi

css - 跨度固定宽度?

转载 作者:太空宇宙 更新时间:2023-11-03 20:29:51 24 4
gpt4 key购买 nike

我正在使用 Boostrap CSS 来“向右拉”列表项中的一些内联按钮。我想在那里修复按钮,所以我设置了文本容器的宽度以防止它分流按钮。只是,它不起作用。

#mybox {
width: 400px;
}

.myli {
background-color: yellow;
}

.mytext {
width: 250px !important;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div id="mybox">


<ol>
<li class="myli list-group-item clear-fix"><span class="mytext">Some text</span><span class="pull-right"><button>
Button
</button></span></li>
<li class="myli list-group-item clear-fix"><span class="mytext">Some text</span><span class="pull-right"><button>
Button
</button></span></li>
<li class="myli list-group-item clear-fix"><span class="mytext">Some very long text which interferes with the button on the following row oiwiowh wdoihsoih osdih ohsdih soidhoishisdhoidh soidh odih</span><span class="pull-right"><button>
Button
</button></span></li>
<li class="myli list-group-item clear-fix"><span class="mytext">Some text</span><span class="pull-right"><button>
Button
</button></span></li>
</ol>

这是一个显示第三行按钮被分流的 fiddle ,尽管我限制了它前面的文本跨度的宽度:

https://jsfiddle.net/3q7ha8fo/1/

最佳答案

在span中添加display: inline-block即可解决:

span {
display: inline-block;
}

fiddle :

#mybox {
width: 400px;
}

.myli {
background-color: yellow !important;
}

.mytext {
width: 250px;
}
span {
display: inline-block;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div id="mybox">


<ol>
<li class="myli list-group-item clear-fix"><span class="mytext">Some text</span><span class="pull-right"><button>
Button
</button></span></li>
<li class="myli list-group-item clear-fix"><span class="mytext">Some text</span><span class="pull-right"><button>
Button
</button></span></li>
<li class="myli list-group-item clear-fix"><span class="mytext">Some very long text which interferes with the button on the following row oiwiowh wdoihsoih osdih ohsdih soidhoishisdhoidh soidh odih</span><span class="pull-right"><button>
Button
</button></span></li>
<li class="myli list-group-item clear-fix"><span class="mytext">Some text</span><span class="pull-right"><button>
Button
</button></span></li>
</ol>

</div>

关于css - 跨度固定宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44675253/

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