gpt4 book ai didi

html - div 内的中心 Bootstrap 3 按钮工具栏

转载 作者:太空宇宙 更新时间:2023-11-04 13:36:41 24 4
gpt4 key购买 nike

如何使 col-lg div 中的 bootstrap 3 btn-toolbar 按钮水平居中?

      <div class="col-lg-6 col-sm-3 noleftpad">
<div class="well topnestedbut">
<div class="btn-toolbar nested-top">
<button type="button" class="btn btn-default btn-sm"><strong>This must be centered</strong></button>
</div>
</div>
</div>

CSS:

.btn-toolbar.nested-top{
position:absolute;
top:0px;
text-align:center;
}

.well.topnestedbut{
padding:35px 10px 10px;
}

.noleftpad{
padding-left:0px;
}

我希望按钮附加到容器 div 的顶部,并且也居中: enter image description here

最佳答案

这是我做的:

当元素定位为绝对时,它会 float 在内容之上。在这种状态下,它只会占用与其内部内容一样多的空间。

如果您将该元素的宽度设置为 100%,它将占据父(或相对)容器宽度的 100%。

http://jsfiddle.net/Per3m/3/

.btn-toolbar.nested-top{
text-align:center;
position:absolute;
top:0;
width:100%;
}

关于html - div 内的中心 Bootstrap 3 按钮工具栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23003837/

24 4 0
文章推荐: php - 如何在不使用 strip_tags 的情况下从变量中删除
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com