Reputation: 1629
How can i fix the unwanted margin of the "right" div.
The right floated div is margined like you can see here: JSFIDDLE: http://jsfiddle.net/s9Ssh/1/
The effect i wanted to achieve is to keep .mid layer always centered no matter the lenght of side div's text.
HTML:
<div class="main">
<div class="left">left</div>
<div class="mid">
<a href="#">Vpis podjetja</a>
|
<a href="#">Iskanje</a>
</div>
<div class="right">right</div>
CSS:
.main {
text-align:center;
width:100%;
}
.left {
float:left;
}
.mid {
}
.right {
float:right;
}
Upvotes: 0
Views: 264
Reputation: 2199
Maybe this will help: http://jsfiddle.net/sbhomra/s9Ssh/4/
I have basically absolutely positioned the left and right div's and set the middle div to stay in the center by using margin:0 auto
.
Fixed padding on left and right div's, so they are not too close the side of the page.
Upvotes: 2
Reputation: 763
Move the right floated element before the middle element in the markup. It appears on a new row because the middle element isn't floated (and is a block level element).
Alternatively you can also float the middle element or set it to inline/inline-block.
EDIT: Although to clarify, if you float the mid element then you have to fiddle around with css a little since it will break your text-align. :P
Upvotes: 1
Reputation: 123377
try to add display: inline-block;
to .mid
element
example fiddle : http://jsfiddle.net/XSdJA/
Upvotes: 1