Reputation: 5808
I have a footer div with 2 texts parts. I want the first one to be on the left side, and the second to be in the middle - and it's position wont be disturbed by the screens page.
(image: move the red part to the pink one.)
I made a jsfiddle example so it will maybe help you in the end of this post -
HTML:
<div class="footer">
<span style="float:left;">Copyright © 2014 blaclaclaclacl All rights reserved.</span>
<span style="margin: 0 auto;">
<a href="javascript:void(0)" onclick="$('#extpopup').show('slow');return false;" class="copy">Terms & Conditions</a>
</span>
<div style="clear:both"></div>
</div>
CSS:
.footer{
border:1px solid black;
}
Upvotes: 0
Views: 57
Reputation: 3741
add the class center
to your second span and adjust the css to the following.
<div class="footer">
<span style="float:left;">Copyright © 2014 blaclaclaclacl All rights reserved.</span>
<span class="center">
<a href="javascript:void(0)" onclick="$('#extpopup').show('slow');return false;" class="copy">Terms & Conditions</a>
</span>
<div style="clear:both"></div>
</div>
.footer{
border:1px solid black;
position: relative;
}
.center{
display:block;
position:absolute;
top:0;
left:0;
width:100%;
text-align: center;
}
see http://jsfiddle.net/dfn2wepv/3/
Or if you really want to do it inline.
<div class="footer">
<span style="float:left;">Copyright © 2014 blaclaclaclacl All rights reserved.</span>
<span style="display:block; position:absolute; top:0; left:0; width:100%; text-align: center;">
<a href="javascript:void(0)" onclick="$('#extpopup').show('slow');return false;" class="copy">Terms & Conditions</a>
</span>
<div style="clear:both"></div>
</div>
Upvotes: 2
Reputation: 1477
You want to provide width
<span style="float:left;width: 50%;">
Copyright © 2014 blaclaclaclacl All rights reserved
</span>
<span style="margin: 1px auto 0px;width: 50%;text-align:center;">
Upvotes: 1
Reputation: 15802
Split it into columns of some kind: http://jsfiddle.net/dfn2wepv/1/
Using classes rather than nth-of-type
is worth doing as well, this is just proof-of-concept.
.footer{
border:1px solid black;
}
.footer span {
display: inline-block;
}
.footer span:nth-of-type(1) {
width: 30%;
}
.footer span:nth-of-type(2) {
text-align: center;
width: 40%;
}
Upvotes: 1