Solved

2 column layout - smooth resize

Posted on 2004-08-19
5
787 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

739 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