Reputation: 75
Here is a link: http://jsfiddle.net/zCXMv/18/
I can not figure out how to get this working. Please help.
HTML:
<div id="button" >
<a class="button1 active" rel="1"></a>
<a class="button2" rel="2"></a>
<a class="button3" rel="3"></a>
<a class="button4" rel="4"></a>
</div>
CSS:
.button1,
.button2,
.button3,
.button4 {
background:#999;
padding:6px;
display:block;
float:left;
margin-right:5px;
}
#button {
width: 50%;
border-width: 1px;
border-style: solid;
height: 30px;
margin-left: auto;
margin-right: auto;
}
Upvotes: 0
Views: 66
Reputation:
Try this.It may work:
#button a{display:block;margin:0 auto !important;text-align:center !important;}
Upvotes: 0
Reputation: 1373
Remove the "display: block" and "float:left" on the buttons, and add "text-align: center" to the #button definition.
Display "inline-block" is not supported in all browsers, so I would recommend not using this unless you absolutely have to.
Upvotes: 0
Reputation: 4063
I made the buttons display: inline-block
, removed the float
s and added text-align: center
to the parent.
.button1,
.button2,
.button3,
.button4
{
background:#999;
padding:6px;
display: inline-block; // Changed from "block"
margin-right:5px;
// Removed floats
}
#button
{
width: 50%;
border-width: 1px;
border-style: solid;
height: 30px;
margin-left: auto;
margin-right: auto;
text-align: center; // Added central alignment to content
}
<div id="button" >
<a class="button1 active" rel="1"></a>
<a class="button2" rel="2"></a>
<a class="button3" rel="3"></a>
<a class="button4" rel="4"></a>
</div>
Upvotes: 3
Reputation: 594
Try this css
.button1,
.button2,
.button3,
.button4 {
background:#999;
padding:6px;
display:block;
float:left;
margin-right:5px;
}
#button {
width: 50%;
border-width: 1px;
border-style: solid;
height: 30px;
margin: 0px auto;
}
Upvotes: 0