User Tools

Site Tools


css:horizontally_center_a_row_of_floated_elements

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
css:horizontally_center_a_row_of_floated_elements [2020/05/20 09:53] – created petercss:horizontally_center_a_row_of_floated_elements [2021/08/08 12:43] (current) – removed peter
Line 1: Line 1:
-====== CSS - Horizontally center a row of floated elements ====== 
- 
-Wrap the container in an element with: 
- 
-<code css> 
-float: right; 
-position: relative; 
-left: -50%; 
-</code> 
- 
-On the main container, add the following: 
- 
-<code css> 
-position: relative; 
-left: 50%; 
-</code> 
- 
-That’s really all there is too it. 
- 
----- 
- 
-===== Example ===== 
- 
-<code css> 
-#menu { 
-  float: right; 
-  position: relative; 
-  left: -50%; 
-} 
-#menu ul { 
-  position: relative; 
-  left: 50%; 
-} 
-#menu li { 
-  float: left; 
-} 
-</code> 
- 
-<code html> 
-<div id="menu"> 
-  <ul> 
-    <li><a href="#">Link 1</a></li> 
-    <li><a href="#">This is long...</a></li> 
-    <li><a href="#">Link 3</a></li> 
-    <li><a href="#">http://www.upshots.org/</a></li> 
-    <li><a href="#">Link 5</a></li> 
-  </ul> 
-</div> 
-</code> 
  
css/horizontally_center_a_row_of_floated_elements.1589968393.txt.gz · Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki