Log in

View Full Version : Fix Floating Elements



Deadweight
10-27-2015, 01:54 AM
So I am testing something to center elements in a UL. However, if I try to push one end using


left:50%; transform:translateX(-50%);

and squeeze the page it seems to not want to stay all on one line.

Here is an example:
http://thebcelements.com/GCG/

Beverleyh
10-27-2015, 07:01 AM
To center li elements, declare text-align:center; on the ul, and set the li elements as display:inline-block; instead http://jsbin.com/yageduruqu/edit?html,css,output

There is a gap around inline-block elements though so, to counteract it, you can bunch up the markup so that the li tags sit together on one line, or comment out the new-line between them (demo does the latter)