473,395 Members | 2,151 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Clear 3 out of 4 floats

KeredDrahcir
426 256MB
I'm using floating division to create a 4 column layout. I'm floating the first column to the left to cotain the menu. Then I've got a second div which contains the last three divs. However I want to put a footer under those three but not the menu div but if I use a clear it puts it under the menu div. Is there a way to put it under just the three.
Expand|Select|Wrap|Line Numbers
  1. +-------------------------------------------------------+
  2. |+-----------------------------------------------------+|
  3. ||                BANNER                               ||
  4. |+-----------------------------------------------------+|
  5. |                                                       |
  6. |+---------+ +-----------------------------------------+|
  7. || LEFT    | | +----------+ +-----------+ +----------+ ||
  8. ||         | | |          | |           | |          | ||
  9. ||         | | |          | |           | |          | ||
  10. ||         | | |          | |           | |          | ||
  11. ||         | | |          | |           | |          | ||
  12. ||         | | |          | |           | |          | ||
  13. ||         | | |          | |           | |          | ||
  14. ||         | | |          | |           | |          | ||
  15. ||         | | |          | |           | |          | ||
  16. ||         | | +----------+ +-----------+ +----------+ ||
  17. ||         | |                                         ||
  18. ||         | | +-------------------------------------+ ||
  19. ||         | | |               FOOTER                | ||
  20. ||         | | +-------------------------------------+ ||
  21. |+---------+ +-----------------------------------------+|
  22. +-------------------------------------------------------+
  23.  
I hope the above makes it clear.
Jul 21 '11 #1
2 1463
Rabbit
12,516 Expert Mod 8TB
Are you sure the style is set up correctly?
Expand|Select|Wrap|Line Numbers
  1. <html>
  2.     <head>
  3.         <style>
  4.             .cont {float: left; height: 400px;}
  5.             .in {float: left; height: 400px;}
  6.             .red {background-color: red; width:100px;}
  7.             .blue {background-color: blue; width:300px;}
  8.             .yellow {background-color: yellow; width:100px;}
  9.             .green {background-color: green; width:100px;}
  10.             .purple {background-color: purple; width:100px;}
  11.             #footer {clear:both; width: 300px; height: 100px; background-color: orange;}
  12.         </style>
  13.     </head>
  14.  
  15.     <body>
  16.         <div class="cont red"></div>
  17.  
  18.         <div class="blue">
  19.             <div class="in yellow"></div>
  20.             <div class="in green"></div>
  21.             <div class="in purple"></div>
  22.             <div id="footer" class="blue"></div
  23.         </div>
  24.     </body>
  25. </html>
Jul 21 '11 #2
Death Slaught
1,137 1GB
Hey KeredDrahcir! It's been a while. :)

You're looking for something like this, right?

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3.  
  4.     <head>
  5.         <title></title>
  6.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  7.         <style type="text/css">
  8.  
  9.             * { margin: 0; padding: 0;}
  10.             #wrapper { width: 1000px; height: 724px; border: 1px solid #000; margin: 0 auto;}
  11.  
  12.             #header { height: 100px; padding: 10px; border: 1px solid yellow;}
  13.             #header h1 { border: 1px solid blue;}
  14.  
  15.             #sidebar { width: 300px; height: 600px; border: 1px solid green; float: left;}
  16.  
  17.             #main { width: 696px; height: 600px; border: 1px solid red; text-align: center; float: left;}
  18.             #main .col { width: 155px; height: 460px; border: 1px solid purple; text-align: left; margin: 10px; display: inline-block;}
  19.             #main #footer { width: 694px; height: 100px; border: 1px solid brown; text-align: left;}
  20.  
  21.  
  22.         </style>
  23.     </head>
  24.  
  25.     <body>
  26.  
  27.     <div id="wrapper">
  28.  
  29.         <div id="header">
  30.             <h1>Banner</h1>
  31.         </div>
  32.  
  33.         <div id="sidebar">
  34.             <h1>Left</h1>
  35.         </div>
  36.  
  37.         <div id="main">
  38.  
  39.             <div class="col"></div>
  40.             <div class="col"></div>
  41.             <div class="col"></div>
  42.  
  43.             <div id="footer">
  44.                 <h1>Footer</h1>
  45.             </div>
  46.         </div>
  47.  
  48.     </div>
  49.  
  50.     </body>
  51.  
  52. </html>
Obviously this is a fixed design. The only real issue is that it uses display: inline-block;, which screws with the design in IE7. To fix that you just need to use:

Expand|Select|Wrap|Line Numbers
  1. #main .col { width: 155px; height: 460px; border: 1px solid purple; text-align: left; margin: 10px; display: inline-block; zoom: 1; *display: inline;}

Regards
Death
Jul 24 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: Stanimir Stamenkov | last post by:
Take a look at: http://www.geocities.com/stanio/test/ie_and_floats.html Basically I got such content blocks: <div class="someblock"> <img class="preview" ...> <p>...</p> <div...
4
by: Florian Brucker | last post by:
Hi! I've got a problem with float & clear. Take this example code: <div style=" width:100px; height:100px; background-color:#FF0000; float:left; margin:10px;"></div> <span...
18
by: Niels | last post by:
Hi group, I have some problems with clearing floated divs. My usual method works fine in Konqueror, but not in Firefox. Here's an example: <html><body> <div id='left' style='float:left;...
9
by: Daz | last post by:
Hello hello! I'm trying to finish off putting my design into HTML and I've come across a problem that I can't get my head around. I've got divs floating in two columns, but I'm having problems...
11
by: Chris Beall | last post by:
Here's the problem: http://pages.prodigy.net/chris_beall/Demo/theproblem.html The page contains inline text, then some additional pairs of text which are floated right and left. (This is a...
3
by: Joel Byrd | last post by:
I've got a 2-column tableless layout and I'm using floats to render the columns. Here are the basic style definitions for the 2 columns: #left_col { width: 59%; float: left; clear: left; }
3
by: freelanceinaz | last post by:
My problem page is at http://girlschorus.org/test.html I have a container with a relatively positioned graphic at the top, then two floats which are relatively positioned (for a a two-column...
13
by: yb | last post by:
Hi, Is there a CSS method to clear a float such that it aligns with the left content edge. For example: X X X X X X X X
1
by: donpro | last post by:
https://testbed.odysseyshipping.com/index.php This is driving me nuts. I've spent much time trying to style this page footer but because I cannot set widths using "display: inline". I've tried...
6
by: Hendrik Maryns | last post by:
Hi, There is a little problem with the header on the page I recently converted from frames to proper HTML+CSS. The top part with the navigation used to be the top frame but is now included via...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.