Reputation: 169
Trying to have my buttons centered above the text below. I think it has to do with my float lefts, but i believe i need to still float it left because the content afterwards is also floating.
Margin: 0 auto; isnt working.
Please Advise:
.button {
background-color: rgb(214,52,49);
padding: 4px 24px;
border-radius: 40px 40px 40px 40px;
color: white;
text-decoration: none;
vertical-align: middle;
text-align: center;
font-size: 2rem;
display: block;
width: 150px; /* 150 / 980 */
}
nav {
width: 100%;
float: left;
margin: 0 0 1em 0;
padding: 0;
background-color: green;
border-bottom: 1px solid #ccc;
text-align: center;
vertical-align: text-top;
}
nav a.button {
float: left;
margin: 0 auto;
}
nav a.button:not(:first-child) {
margin-left: 150px;
}
http://jsfiddle.net/117sparten/kNZEs/3/
Upvotes: 0
Views: 1560
Reputation: 6709
<header>
<nav>
<div class="btngroup">
<a href="#" class="button">contact</a>
<a href="#" class="button">blog</a>
</div>
</nav>
</header>
.button {
background-color: rgb(214,52,49);
padding: 4px 24px;
border-radius: 40px 40px 40px 40px;
color: white;
text-decoration: none;
text-align: center;
font-size: 2rem;
display: inline-block;
width: 150px; /* 150 / 980 */
}
.button:not(:first-of-type) {
margin-left: 10px;
}
nav {
width: 100%;
float: left;
margin: 0 0 1em 0;
padding: 0;
background-color: green;
border-bottom: 1px solid #ccc;
text-align: center;
vertical-align: text-top;
}
nav div.btngroup {
width: 410px;
margin: auto;
height:
}
nav a.button {
float: left;
margin: 0 auto;
}
Upvotes: 1
Reputation: 6124
use this inline-block property in button class
.button
{
display:inline-block;
}
and remove float property from nav a.button
Upvotes: 1
Reputation: 11
Try change nav a.button
like this:
nav a.button {
display: inline-block;
margin: 0 auto;
}
or
nav a.button {
display: inline;
margin: 0 auto;
}
Upvotes: 1