Solved

2 column layout - smooth resize

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jQuery CSS Scroll Issue 3 72
Adding a hidden div to each row in a table 6 61
Text in block not displaying properly 2 33
form button worked now it doesnt anymore 9 39
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
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!
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…
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…

919 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

17 Experts available now in Live!

Get 1:1 Help Now