I want a horizontally centered "floating" div, i.e. one that always is on top of the screen even if the user scrolls around.
With the following CSS I get the div centered completely on the left:
#guiBar {
margin-left: auto;
margin-right: auto;
position: fixed;
}
margin: 0 auto
doesn't help either (presumably because that doesn't work together with position: fixed
?
I don't really care how the solution works so javascript or some html5 trickery would be just as fine as pure css. I already tried the solution found here from starx but that also doesn't seem to work with position: fixed. there's also this which doesn't work either (i.e. it's left centered - not sure if a number of <input class="guiButton" type="image" src="/icons/some.png" />
have a fixed size by his definition.)