Reputation: 15
How to centering that download button? I tested many times but it's wrong codes.
.col {
width: 100%;
height: auto;
float: left;
}
.download {
width: auto;
font-weight: 600;
font-size: 14px;
color: #000;
border: 2px solid #000;
padding: 17px 37px;
margin-top: 30px;
float: left;
}
<div class="col">
<span class="download">Download</span>
</div>
Upvotes: 1
Views: 88
Reputation: 8695
Remove float:left;
from .download
(because it forces the element to be floated to the left).
Give display:inline-block;
(It acts like inline
element, it means you can center it by giving text-align:center;
to its parent.)
.col {
width: 100%;
height: auto;
float: left;
text-align: center;
}
.download {
font-weight: 600;
font-size: 14px;
color: #000;
border: 2px solid #000;
padding: 17px 37px;
margin-top: 30px;
display: inline-block;
}
Upvotes: 2
Reputation: 2140
Just add text-align: center;
to .col
and replace float:left
with display:inline-block;
in the button element. jsfiddle
Upvotes: 3