Forum Moderators: not2easy
Thank you for your advice!
code:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<style>
body {
background:#FF9999;
width: 100%;
padding: 0; margin: 0;
}
html {padding: 0; margin: 0;}
.width100 {
width: 100%;
float: left;
clear: both;
}
.bg_color {
background-color: #00CCFF;
height: 100%;
display: block;
clear: none;
float: left;
width: 100%;
}
.pad_add01{
padding: 20px;
float: left;
border: 2px solid #CCCCCC;
margin-right: 5px;
overflow: visible;
margin-left: 5px;
margin-top: 2px;
margin-bottom: 2px;
}
.width50_left {
width: 50%;
display: inline;
float: left;
background-color: #FFFF99;
text-align: justify;
vertical-align: top;
margin: 0px;
padding-top: 5px;
padding-right: 0px;
padding-bottom: 5px;
padding-left: 0px;
overflow: hidden;
position: relative;
visibility: visible;
clear: right;
font-family: "Arial", "Helvetica", "sans-serif";
font-size: 12px;
}
.width50_right {
width: 50%;
display: inline;
float: right;
background-color: #FFCC33;
text-align: justify;
vertical-align: top;
margin: 0px;
padding-top: 5px;
padding-right: 0px;
padding-bottom: 5px;
padding-left: 0px;
overflow: hidden;
position: relative;
visibility: visible;
clear: right;
font-family: "Arial", "Helvetica", "sans-serif";
font-size: 12px;
*width: 49.99%;
}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div class="width100">
<div class="bg_color">
<div class="width50_left">
<div class="pad_add01">width50 width50 width50
width50 width50 width50 width50 width50 width50
width50 width50 width50 width50 width50 width50
width50 width50 width50 width50 width50 width50
width50 width50 width50 width50 width50
</div>
<div class="pad_add01">width50
</div>
</div>
<div class="width50_right">
<div class="pad_add01">width50 width50 width50
width50 width50 width50 width50 width50 width50
width50 width50 width50 width50 width50 width50
width50 width50 width50 width50 width50 width50
width50 width50 width50 width50 width50
</div>
<div class="pad_add01">width50
</div>
</div>
</div>
</div>
</body></html>
I have simplified the original code further to make the question clearer.
It's supposed to be a 100% width design.
If the user's screen is 800, then there will be 2 columns, each of 400. There will be boxes which contain some content within a column. Assume I need left and right margin surrounding the box, both 20. Then whether the content of the box is "abc" or a very long paragraph, I want the box's width to be
400-(20x2)=360.
Likewise, if the user's screen is 1280, then there will be 2 columns, each of 640. There will be boxes which contain some content within a column. Assume I need left and right margin surrounding the box, both 20. Then whether the content of the box is "abc" or a very long paragraph, I want the box's width to be
640-(20x2)=600.
Now the exact width of the box depends on how long the content is and has not fully occupied the width available, that's the problem. Initially the design is not strange, but to make all browsers happy (e.g. removing the scrollbar at bottom in 1 browser), I've made it increasingly strange:)
Thank you!
code:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<style>
body {
background:#FF9999;
width: 100%;
padding: 0; margin: 0;
}
html {padding: 0; margin: 0;}
.width100 {
width: 100%;
float: left;
clear: both;
}
.bg_color {
background-color: #9999CC;
height: 100%;
display: block;
clear: none;
float: left;
width: 100%;
}
.pad_add01{
padding: 20px;
float: left;
border: 2px solid #FF0000;
margin-right: 5px;
overflow: visible;
margin-left: 5px;
margin-top: 2px;
margin-bottom: 2px;
}
.width50_right {
width: 50%;
display: inline;
float: right;
background-color: #FFCC33;
text-align: justify;
vertical-align: top;
margin: 0px;
padding-top: 5px;
padding-right: 0px;
padding-bottom: 5px;
padding-left: 0px;
overflow: hidden;
position: relative;
visibility: visible;
clear: right;
font-family: "Arial", "Helvetica", "sans-serif";
font-size: 12px;
*width: 49.99%;
}
-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div class="width100">
<div class="bg_color">
<div class="width50_right">
<div class="pad_add01">abc abc abc abc
</div>
</div>
</div>
</div>
</body></html>
.pad_add01{
padding: 20px;
/* float: left; */
border: 2px solid #FF0000;
margin-right: 5px;
/* overflow: visible; */
margin-left: 5px;
margin-top: 2px;
margin-bottom: 2px;
}
the float on that div, without a width is causing the content to be "shrinkwrapped", the overflow is not necessary. the floated outer divs are enough to halve the page with the inner providing your required padding and/or margin