Html 引导3:垂直居中按钮
我想将一组按钮垂直居中放置在一列中(见图)。行的高度是动态的。我已经尝试了很多我发现的东西,但都不管用 截图:Html 引导3:垂直居中按钮,html,css,twitter-bootstrap,twitter-bootstrap-3,Html,Css,Twitter Bootstrap,Twitter Bootstrap 3,我想将一组按钮垂直居中放置在一列中(见图)。行的高度是动态的。我已经尝试了很多我发现的东西,但都不管用 截图: 动态内容 1 2 3 4 5. 以下是我的全部代码: 有人有主意吗 我用的是bootstrap3 提前谢谢 试试这个: .question{ position: relative; } .r-answer{ position: static; } .r-answer .btn-group{ position: absolute; top: 50%;
动态内容
1 2
3 4
5.
以下是我的全部代码:
有人有主意吗
我用的是bootstrap3
提前谢谢 试试这个:
.question{
position: relative;
}
.r-answer{
position: static;
}
.r-answer .btn-group{
position: absolute;
top: 50%;
margin-top: -17px;
}
只要按钮的大小保持不变,这将使它们对齐中心,否则您将需要javascript来修复它。有点晚,但尝试使用按钮组垂直类而不是按钮组:
<div class="btn-group-vertical" data-target="question3" data-toggle="buttons-radio">
<button class="btn btn-primary" data-toggle="button" type="button" value="1">1</button> <button class="btn btn-primary" data-toggle="button" type="button" value="2">2</button>
<button class="btn btn-primary" data-toggle="button" type="button" value="3">3</button> <button class="btn btn-primary" data-toggle="button" type="button" value="4">4</button>
<button class="btn btn-primary" data-toggle="button" type="button" value="5">5</button>
</div>
1 2
3 4
5.
是修改后的代码div不是表。按钮div与文本div不匹配。也许您应该多写一点您到目前为止尝试过的内容。谢谢您的解决方案!很好用!按钮的大小保持不变。
<div class="btn-group-vertical" data-target="question3" data-toggle="buttons-radio">
<button class="btn btn-primary" data-toggle="button" type="button" value="1">1</button> <button class="btn btn-primary" data-toggle="button" type="button" value="2">2</button>
<button class="btn btn-primary" data-toggle="button" type="button" value="3">3</button> <button class="btn btn-primary" data-toggle="button" type="button" value="4">4</button>
<button class="btn btn-primary" data-toggle="button" type="button" value="5">5</button>
</div>