Solved

2 column layout - smooth resize

Posted on 2004-08-19
5
785 Views
Last Modified: 2008-01-09
hello all!

Please see my code below and tell me why when you shrink the page horizontally, sometimes the blog div shifts down, and sometimes it doesnt.  what do i need to add to my css to make it resize smoothly?  thanks a bunch!

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>

<style type="text/css">
<!--

body {
      background-color: #003366;
      margin: 0px;
      font-size: 8pt;
      font-family: georgia, verdana;
      }

.main {
      width: 90%;
      height: 100%;
      background-color: #003366;
      }
      
.header {
      color: #003366;
      width: 100%;
      height: 20%;
      background-color: #00ffff;       
      padding: 5px;
      }
      
.menu {
      color: #ffffff;
      width: 25%;
      height: 100px;
      background-color: #003366;
      float: left;
      padding: 5px;
      }
      
.blog {
      color: #ffffff;
      width: 75%;
      height: 100%;
      background-color: #3399cc;
      float: right;
      padding: 5px;
      text-align: center;
      }
      
.blogtitle {
      font-size: 12pt;
      font-weight: bold;
      }
      
.blogheader {
      width: 90%;
      background-color: #003366;
      margin-bottom: 5px;
      }      
      
.blogcontent {
      width: 90%;
      background-color: #003366;
      }

-->
</style>

</head>
<body>

<div class="main">
      <div class="header">
            Header
      </div>
      <div class="menu">
            Menu
      </div>
      <div class="blog">
            <div class="blogheader">
                  <div class="blogtitle">Title</div>
            </div>
            <div class="blogcontent">
                  Content
            </div>            
      </div>
</div>

</body>
</html>
0
Comment
Question by:flow79
  • 3
  • 2
5 Comments
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 500 total points
ID: 11846424
Anytime you use height:100% you are basically saying to the browser "guess what size I want this to be".  What is 100% of the height of the body... all the content of the page... but the height of the content is not known because it is defined as 100% of the body whose height cannot be determined without knowing the content height. So rather then hanging on an unresolvable recusive calculation.  The browser just arbitrarily renders the page. I will get it close off the load most of the time, but re-size is a crap shoot, because the dom gets really messed.

You need to re-think what you are trying to do with this, anchor it with some specific height values, or leave the height out altogether and do whatever setting of height you need to do with script.

Cd&
0
 
LVL 13

Author Comment

by:flow79
ID: 11851433
C&d,
  I've removed all of the height: 100% values. However, I still have the .header, and .blogheader set with absolute height values - the page still breaks when its resized horizontally.  any more ideas?
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 11864442
I need to see the new code or a link to the page.

Cd&
0
 
LVL 13

Author Comment

by:flow79
ID: 11869787
I actually just recoded it without heights, and it seems to work fine.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>2 column layout with divs</title>
<style type="text/css">
<!--
body { background-color: #ffffcc; }
.main {
      width: 800px;
      background-color: #003366;
      }
.header {
      width: 800px;
      height: 75px;
      background-color: #3399cc;
      padding: 10px;
      }
.left {
      width: 50%;
      background-color: #0000ff;
      float: left;
      margin-bottom: 20px;
      padding: 10px;
      }
.right {
      width: 50%;
      background-color: #ffffff;
      float: right;
      margin-bottom: 20px;
      padding: 10px;
      }
-->
</style>
</head>
<body>
<div class="main">
      <div class="header">
      Header
      </div>
      <div class="left">
      left
      </div>
      <div class="right">
      right
      </div>
</div>
</body>
</html>


Thanks C&d for letting me know about the height issue.

you get the points!
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 11870124
Yeah with CSS sometimes less is better.  The browser will try to optimize but if you restrict it too much it gets jammed.  Of course we blame the browser or the CSS when that happens, but 99% of problems on a page are developer error; we just need to work with the tchnologies.  Glad I could help.  Thanks for the A. :^)

Cd&
0

Featured Post

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question