OMG, Really I’ve been here a thousand times before. I am so going to snippet this answer.
I cannot believe how hard it is to do something as easy as this.
<body>
<div class="wrapper">
<div class="class1">Page 1 of 1</>
<div class="class1"> — </>
<div class="class1">Next</>
</div>
</body>
I need the wrapper to be dead centre to the browser. Doesn’t matter what the length of the text within is, or the amount of divs. How on earth does one do this?! I’m freaking out here. I’m not that bad at CSS. Googling this turns up forum posts from 2005. Or answers are found because the width was specified so that’s just cheating.
Hair is being pulled out!
I won’t put my CSS in here cos it’s just not working, theres no point.
Thanks.
Working jsfiddle: http://jsfiddle.net/6utN2/1/
I think you’d have been better off coding this with a
ULand using theLIfor your 3 elements.Here’s why:
.wrapperMUST act as the container for those 3divsbecause you’ve floated them – taking them out of the document flow.The only way to reign in the problem caused by this is to wrap your wrapper…which is not the leanest solution one could write.
The
ULtechnique works great here, though not that intuitive at first, BUT theULis the container,LIs can all float left (and will stay nested within their parent). Finally, a single div could be used to span whatever element theULresides, and center it.ps – I used .fauxBody as the wrapping wrapper – just a heads up.