Solved

2 column layout - smooth resize

Posted on 2004-08-19
5
783 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

707 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now