Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Float left and right

Tags:

css

css-float

this problem has been bothering me for some time. So I have created some visual descriptions of my problem

First here is my HTML structure I have 6 divs.. the first 3 float left and the last 3 float right. The last image shows the result I want but can't seem to get. Can someone out there help me here

EDIT// Sorry heres my HTML and CSS

<style>     .left { float:left; }     .right { float:right; } </style> <div id="container">    <div class="left"></div>    <div class="left"></div>    <div class="left"></div>    <div class="right"></div>    <div class="right"></div>    <div class="right"></div> </div> 

NOTE: I Cant do a left right left right left right option because Im getting my data from PHP via a Query to my database.. first query goes left second query goes right.... thanks a bunch

/EDIT

This is a mocukup of my HTML structure

My floats result in this

this is my current result

This is what I want

I want this

like image 576
Oldenborg Avatar asked Jun 12 '12 10:06

Oldenborg


People also ask

What is float left and float right?

left : floats the element to the left of its container. right : floats the element to the right of its container. inherit : the element inherits the float direction of its parent.

What does float left mean?

The float CSS property places an element on the left or right side of its container, allowing text and inline elements to wrap around it. The element is removed from the normal flow of the page, though still remaining a part of the flow (in contrast to absolute positioning).

What is style float right?

Introduction to CSS Float Right. Float property of CSS allows the texts and inline elements to wrap around it either on the left or right side of the element. This float property of CSS forces the layout elements to float inside the parent element along with which other elements wrap around it.


1 Answers

Float one left , one right, and give first the clear:both property

<div class="left clear"></div> <div class="right"></div> <div class="left clear"></div> <div class="right"></div> 

css

.left {float:left} .right {float:right} .clear {clear:both} 

Example

like image 193
khaled_webdev Avatar answered Nov 09 '22 23:11

khaled_webdev