html - Simple CSS layout - how can I achieve this layout, and make it scale easily? -
O people, how can I get this simple layout? I hope the answer will help me understand CSS layouts and floats.
& lt; Div id = "verticalElement1" & gt; & Lt; Div id = "horizontal element 1" & gt; Some content & lt; / Div & gt; & Lt; Div id = "horizontal element 2" & gt; Some content & lt; / Div & gt; & Lt; Div & gt; & Lt; Div id = "vertical alignment 2" & gt; & Lt; Div id = "vertical alignment 3" & gt; Some content & lt; / Div & gt; & Lt; Div id = "vertical alignment 4" & gt; Some content & lt; / Div & gt; & Lt; Div & gt; OK, therefore, as a suggestion of "ID", I want to put vertical elements on each other's head . Inside the top element, I want to place 2 horizontal elements next to each other. I do not want to use the full position, except that without any
.
I would like to get it all very clean and scalable with CSS, in such a way that I can add and remove elements without changing the style values. Everything should be done by applying the appropriate sections to some elements, something like this:
I tried to float but everything goes crazy .... help!
Cheers
Your vertical container should be displayed as a block, By default, the div
tags are their internal content, either the two can be omitted, or one left and one right. You can also set the width on your horizontal elements to make sure that they actually end up on the same line.
Your HTML may look like this:
& lt; Div id = "container1" class = "container" & gt; & Lt; Div class = "inner element" & gt; & Lt; / Div & gt; & Lt; Div class = "inner element" & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div id = "container2" class = "container" & gt; & Lt; Div class = "inner element" & gt; & Lt; / Div & gt; & Lt; Div class = "inner element" & gt; & Lt; / Div & gt; & Lt; / Div & gt;
CSS may look like this:
.near-element {float: left; Width: 100px; }
Also, you should remember to empty the floats for all your containers:
.container {min-height: 10px;} Container: after {content: "."; Display area; Height: 0; Clean both; Visibility: hidden; }
Of course, you want to give your divs more accurate name, such as "content" or "cover" or something that actually describes their purpose that they The name of the "content" name
Comments
Post a Comment