[英]How can i line up a group of buttons next to a bootstrap 3 panel title using CSS?
I'm trying to learn some bootstrap 3, and i'm trying to add a group of two buttons to a panel heading for those Collapse-Accordion's . 我正在尝试学习一些Bootstrap 3,并且正在尝试向面板标题中的Collapse-Accordion's添加两个按钮。 I want to be able to line the title of the panel to the left, and the btn-group
lined to the right. 我希望能够将面板的标题排在左侧,而btn-group
排在右侧。
I have tried to add pull-left
for the title, and pull-right
for the button group, but this will not result in something pretty... 我试图为标题添加pull-left
,为按钮组添加pull-right
,但这不会产生一些漂亮的结果。
Adding for example: style="margin-left:200px;"
例如添加: style="margin-left:200px;"
to the <span>
, will work, but when i add more panels, with different names, there will be another number of px for that margin... 到<span>
,将起作用,但是当我添加更多名称不同的面板时,该边距将有另一个px。
Here is a link to my JSfiddle. 这是我的JSfiddle的链接。
Where i go wrong is probably somewhere here: Not sure if i can use the <span>
within the <h4>
, and for this purpose of mine? 我出问题的地方可能在这里:不知道我是否可以在<h4>
使用<span>
<h4>
,并且出于我的目的?
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
Click me...
</a>
<span class="btn-group">
<button class="btn btn-default">ON</button>
<button class="btn btn-primary active">OFF</button>
</span>
</h4>
</div>
pls try the below code, and here is the fiddle 请尝试下面的代码,这是小提琴
<div class="panel-heading">
<h4 class="panel-title">
<div class="row">
<div class="col-md-12">
<div class="col-md-6">
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">Click me...
</a>
</div>
<div class="col-md-6 text-right">
<span class="btn-group">
<button class="btn btn-default">ON</button>
<button class="btn btn-primary active">OFF</button>
</span>
</div>
</div>
</div>
</h4>
</div>
if you change some of the css rules for the panel-head and btn-group it work. 如果您更改面板标题和btn-group的某些CSS规则,它将起作用。
.btn-group{
position: absolute;
right: 8px;
top: 8px;
}
.panel-heading{
position: relative;
}
http://jsfiddle.net/q8qCW/1/ http://jsfiddle.net/q8qCW/1/
I would suggest, not to add these rules to every panel-head and btn-group ^^. 我建议不要将这些规则添加到每个面板标题和btn-group ^^。 I also change the size of the btn-group to. 我还将btn-group的大小更改为。
btn-group-xs
It is not a very dynamic way if doing it, but gets the job done. 如果这样做不是很动态的方法,但是可以完成工作。 Other sizes of btn-groups are possible, but require different top and right css rules. 可以使用其他大小的btn-group,但是需要不同的顶部和右侧CSS规则。
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">Click me...
</a>
<span class="btn-group col-md-offset-9">
<button class="btn btn-default">ON</button>
<button class="btn btn-primary active">OFF</button>
</span>
Hi i have forked your code to js fiddle and added some class and media queries(for idea), please try to improve media queries as well. 嗨,我已将您的代码分叉给js小提琴,并添加了一些类和媒体查询(以供参考),请尝试同时改进媒体查询。
How about using a list-inline
.. 如何使用list-inline
..
<div class="panel panel-default">
<div class="panel-heading">
<div class="panel-title">
<ul class="list-inline">
<li class="col-xs-12">
<span class="btn-group pull-right">
<button class="btn btn-default">ON</button>
<button class="btn btn-primary active">OFF</button>
</span>
<h4>
<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
Click me...
</a>
</h4>
</li>
</ul>
</div>
</div>
</div>
Demo: http://bootply.com/92157 演示: http : //bootply.com/92157
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.