[英]Anchor goes to whole width when centered
I've one paragraph and one button in my container like this我的容器中有一个段落和一个按钮,就像这样
<div class="container">
<div class="row">
<p class="text-center text-muted">text</p>
<a class="btn btn-danger center" href="">
Download PDF
</a >
</div>
</div>
code for my center class is我的中心班的代码是
.center{
display: block !important;
margin-left: auto !important;
margin-right: auto !important;
}
and this is how output looks like while i was expecting to be in center with small button that should be wide as per its value like Download Pdf这就是输出的样子,而我希望小按钮位于中心,小按钮应该根据其值而宽,例如下载 Pdf
Your style should be like:你的风格应该是这样的:
.center {
display: block !important;
width: 250px; //change accordingly;
margin-left: auto !important;
margin-right: auto !important;
}
Margin auto works well with fixed width container.自动边距适用于固定宽度的容器。
Or try:或尝试:
<div style='text-align:center'>
<a class="btn btn-danger" href="">
Download PDF
</a >
</div>
Just an advice, avoid using too many !important
只是一个建议,避免使用太多!important
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.