How to keep div's always at full width? - css

Is there a way to prevent a DIV from cutting out from a dynamic filed content? when content is large enough it stays full width and zooms fine but when it's small it breaks off from top group.
Here is a copy of my html & css:
<style>
#title{
font-family: Arial;
font-size: 1.5em;
font-weight: bold;
text-align: center;
background: beige;
padding: 7px 50px 7px 50px;
margin: 10px 0px 0px 0px; /* L&R margins need to be 0px */
}
#box1{ /* Outer Box */
float: left;
font-size: 1em;
text-align: justify;
background: beige;
margin: 0px; /* L&R margins need to be 0px */
padding: 0px 50px 10px 50px;
}
#box2{ /* Inner Box */
font-family: Arial;
float: right;
width: 50%;
font-weight: bold;
font-size: 1em;
text-align: justify;
background: beige;
margin: 0px; /* L&R margins need to be 0px */
padding: 0px 0px 0px 50px;
display: block;
}
#box3{ /* Footnotes */
margin: 0px;
float: left;
font-size: 1em;
text-align: justify;
background: beige;
padding: 0px 50px 30px 50px;
border-radius: 0px 0px 15px 15px;
}
#footnote_columns{
display: block;
overflow:hidden;
/*columns: auto auto; /* column-count: auto column-width: auto; */
column-fill: balance; /* not working!!! */
column-count: 3;
-moz-column-count: 3;
-webkit-column-count: 3;
column-width: auto;
-moz-column-width: auto;
-webkit-column-width: auto;
column-gap: 2em;
-moz-column-gap: 2em;
-webkit-column-gap: 2em;
}
</style>
<!-- ====================== Page Title ===================== -->
<div id='title'>
<HR>
'Title' centered & full width
<HR>
</div>
<!-- ============ text box inside text box ================ -->
<div id="box1"> <!-- Left Side -->
<div id="box2"> <!-- Right Side -->
<p>
INNER Box2 text: " Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas sed nibh eu velit iaculis auctor non ac magna. In at enim quis mi aliquam vestibulum imperdiet eu magna. Ut aliquet arcu at felis dapibus euismod. Suspendisse dolor turpis, faucibus quis mollis vitae, iaculis vel urna. Integer sit amet dui malesuada justo facilisis rutrum sed vel neque. Cras condimentum est sit amet mi dapibus convallis. Donec molestie euismod velit id pharetra. Praesent sit amet eros at quam ullamcorper sodales. Aenean ligula dui, ultricies quis commodo ut, lobortis eu justo. Nulla dolor augue, vulputate at placerat in, ornare et purus. "
</p>
<HR>
</div>
<p>
OUTER Box1 text: " Etiam at pretium urna. Morbi condimentum consequat nisi, nec pulvinar tellus fermentum at. Cras ut sodales ante. Sed feugiat sem eget eros lobortis sit amet porttitor mauris tempus. Sed eros est, placerat at sollicitudin quis, scelerisque ac dolor. Proin mollis euismod condimentum. Morbi eget tortor justo, eu vestibulum orci. Pellentesque eu ante a nunc adipiscing sodales dictum vitae eros. Sed tellus mauris, volutpat non vulputate ut, vulputate ut orci. Vivamus facilisis ipsum a tellus gravida pellentesque. Nam risus magna, eleifend dignissim porttitor et, sagittis quis nisl.
Sed eget lorem magna. Sed sed imperdiet elit. Sed vulputate dapibus tellus, nec scelerisque risus hendrerit quis. Fusce aliquet erat non nibh egestas posuere. Aliquam ipsum velit, venenatis vel dictum ac, luctus nec sapien. In hac habitasse platea dictumst. Vivamus a elit augue. Integer pellentesque enim sit amet sem condimentum ut tincidunt nunc mollis. Cras in tellus eget dui pellentesque adipiscing. In varius ullamcorper felis, vitae sagittis turpis rutrum in. Aliquam consectetur consectetur erat, quis tristique magna laoreet id. Etiam orci arcu, ultricies eget interdum non, mollis quis est. Mauris odio lacus, tempus at porta quis, laoreet porta tortor. "
<HR>
</div>
<div id='box3'>
<div id='footnote_columns'>
<p>
FOOTNOTE Box3 text: " Vivamus egestas tempor molestie. Morbi scelerisque nunc non eros ultrices volutpat. Suspendisse potenti. Sed lobortis, odio vitae pharetra dapibus, risus turpis scelerisque risus, a dapibus dui ante sed ante. "
</p>
</div>
<HR>
</div>
<!-- ======================================================= -->
Example 1 works - has plenty of txt -
Example 2 breaks - when you zooming -
(1) http://jsfiddle.net/NuxWD/1/ - full text
(2) http://jsfiddle.net/NuxWD/2/ - try zooming, notice footnote
(3) http://jsfiddle.net/NuxWD/3/ - small amount of txt in footnote
(4) http://jsfiddle.net/NuxWD/4/ (5) http://jsfiddle.net/NuxWD/5/ - everything breaks!
Need this for dynamic content. If I remove the BR in example (4) the frame stays fine;
How can frame remain in full width even when paragraphs are short?
Notice bottom row, the Footnote, try adjusting amount of txt; or zoom out
IE does not even column footnote at all.
Why is the title not affected at all whether have smalls amount of txt or you zoom out ?

Related

Gap left of header, despite width set to 100% (CSS) [duplicate]

This question already has answers here:
How wide is the default `<body>` margin?
(4 answers)
Closed 7 months ago.
Edit
Apparently my question is similar to a question about the margin width of a document's body. Which is kind of odd, because that question itself is the answer to mine. It's the answers here which refer to that question, and since I'm asking for those answers I can't know that. Hope this makes sense.
I have a webpage with fixed header and footer, for which I set the width to 100%. Nevertheless there is an 8 pixel gap to the left of both. How do I get rid of them?
CSS
#main {
width: 1200px;
height: 100%;
margin: 60px auto 0 auto;
padding: 1em;
}
/* pertaining header ------------------------------------ */
header, #main::before {
height: 60px;
}
header {
position: fixed;
top: 0;
width: 100%;
margin: auto;
background: linear-gradient(180deg, #91C1CC, #468795);
border-bottom: 1px solid black;
}
header div {
width: 1200px;
margin: 0 auto;
padding: 0;
}
header div p {
margin-top: 16px;
margin-left: 1000px;
font-family: Whitehall, Verdana, Geneva, sans-serif;
font-size: 2.5em;
color: white;
}
/* pertaining footer ------------------------------------ */
#container::after {
content: "";
display: block;
}
footer, #main::after {
height: 40px;
}
footer {
position: fixed;
bottom: 0;
width: 100%;
margin: auto;
background: linear-gradient(0, #91C1CC, #468795);
border-top: 1px solid black;
}
footer div {
width: 1200px;
margin: auto;
padding: 1em;
}
#departments {
margin: 0;
padding: 0 1em;
margin-top: -8px;
margin-left: -22px;
font-size: 85%;
}
#departments a {
margin-right: 3em;
color: black;
}
#departments a:link, #departments a:visited {
text-decoration: none;
}
JSfiddle at https://jsfiddle.net/stevenvh/65dao4pt/5/
The 8 pixel gap is cause by the HTML body tag, it has a default margin of 8px on all the four sides.
To get ride of all the gap around the element, just use CSS property of margin: 0; like this,
body {
/* to remove gaps from four sides */
margin: 0;
}
Working Example:
#font-face {
font-family: Whitehall;
src: url('fonts/Whitehall.woff') format('woff'), url('fonts/Whitehall.ttf') format('truetype');
}
body {
font-family: Verdana, Geneva, sans-serif;
line-height: 1.6em;
/* to remove gaps from four sides */
margin: 0;
}
#main {
width: 1200px;
height: 100%;
margin: 60px auto 0 auto;
padding: 1em;
}
/* pertaining header ------------------------------------ */
header,
#main::before {
height: 60px;
}
header {
position: fixed;
top: 0;
width: 100%;
margin: auto;
background: linear-gradient(180deg, #91C1CC, #468795);
border-bottom: 1px solid black;
}
header div {
width: 1200px;
margin: 0 auto;
padding: 0;
}
header div p {
margin-top: 16px;
margin-left: 1000px;
font-family: Whitehall, Verdana, Geneva, sans-serif;
font-size: 2.5em;
color: white;
}
/* pertaining footer ------------------------------------ */
#container::after {
content: "";
display: block;
}
footer,
#main::after {
height: 40px;
}
footer {
position: fixed;
bottom: 0;
width: 100%;
margin: auto;
background: linear-gradient(0, #91C1CC, #468795);
border-top: 1px solid black;
}
footer div {
width: 1200px;
margin: auto;
padding: 1em;
}
#departments {
margin: 0;
padding: 0 1em;
margin-top: -8px;
margin-left: -22px;
font-size: 85%;
}
#departments a {
margin-right: 3em;
color: black;
}
#departments a:link,
#departments a:visited {
text-decoration: none;
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test</title>
</head>
<body>
<div id="container">
<header>
<div>
<p>Main title</p>
</div>
</header>
<div id="main">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam sit amet sem quam. Donec vehicula sed urna a tempor. Mauris facilisis malesuada varius. In ut dapibus lorem. Nullam iaculis tortor eget mauris sagittis, sed elementum mi semper. Aliquam
faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat. Duis elementum, nulla at pulvinar pharetra, ligula purus scelerisque libero, quis fermentum dui ante blandit dui. Vivamus bibendum, mauris vitae hendrerit aliquam,
metus quam elementum est, sed viverra enim ipsum nec dui. Duis rutrum, eros a dignissim laoreet, enim justo feugiat massa, et pretium ex ligula et nunc. Praesent quis quam scelerisque, hendrerit diam in, suscipit felis. Curabitur iaculis congue
augue, sit amet rutrum nisi luctus id. Praesent ac massa quis ligula fermentum laoreet. Vivamus sed faucibus elit. Aliquam faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam sit amet sem quam. Donec vehicula sed urna a tempor. Mauris facilisis malesuada varius. In ut dapibus lorem. Nullam iaculis tortor eget mauris sagittis, sed elementum mi semper. Aliquam
faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat. Duis elementum, nulla at pulvinar pharetra, ligula purus scelerisque libero, quis fermentum dui ante blandit dui. Vivamus bibendum, mauris vitae hendrerit aliquam,
metus quam elementum est, sed viverra enim ipsum nec dui. Duis rutrum, eros a dignissim laoreet, enim justo feugiat massa, et pretium ex ligula et nunc. Praesent quis quam scelerisque, hendrerit diam in, suscipit felis. Curabitur iaculis congue
augue, sit amet rutrum nisi luctus id. Praesent ac massa quis ligula fermentum laoreet. Vivamus sed faucibus elit. Aliquam faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam sit amet sem quam. Donec vehicula sed urna a tempor. Mauris facilisis malesuada varius. In ut dapibus lorem. Nullam iaculis tortor eget mauris sagittis, sed elementum mi semper. Aliquam
faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat. Duis elementum, nulla at pulvinar pharetra, ligula purus scelerisque libero, quis fermentum dui ante blandit dui. Vivamus bibendum, mauris vitae hendrerit aliquam,
metus quam elementum est, sed viverra enim ipsum nec dui. Duis rutrum, eros a dignissim laoreet, enim justo feugiat massa, et pretium ex ligula et nunc. Praesent quis quam scelerisque, hendrerit diam in, suscipit felis. Curabitur iaculis congue
augue, sit amet rutrum nisi luctus id. Praesent ac massa quis ligula fermentum laoreet. Vivamus sed faucibus elit. Aliquam faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam sit amet sem quam. Donec vehicula sed urna a tempor. Mauris facilisis malesuada varius. In ut dapibus lorem. Nullam iaculis tortor eget mauris sagittis, sed elementum mi semper. Aliquam
faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat. Duis elementum, nulla at pulvinar pharetra, ligula purus scelerisque libero, quis fermentum dui ante blandit dui. Vivamus bibendum, mauris vitae hendrerit aliquam,
metus quam elementum est, sed viverra enim ipsum nec dui. Duis rutrum, eros a dignissim laoreet, enim justo feugiat massa, et pretium ex ligula et nunc. Praesent quis quam scelerisque, hendrerit diam in, suscipit felis. Curabitur iaculis congue
augue, sit amet rutrum nisi luctus id. Praesent ac massa quis ligula fermentum laoreet. Vivamus sed faucibus elit. Aliquam faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat.
</p>
</div>
<footer>
<div>
<p id="departments">
◼ About ◼ Contact ◼ Sitemap
</p>
</div>
</footer>
</div>
</body>
</html>
HTML's body tag has a margin on all sides set by default. By adding margin: 0 to your body you can fix that quite easily.
#font-face {
font-family: Whitehall;
src: url('fonts/Whitehall.woff') format('woff'),
url('fonts/Whitehall.ttf') format('truetype');
}
body {
font-family: Verdana, Geneva, sans-serif;
line-height: 1.6em;
margin: 0;
}
#main {
width: 1200px;
height: 100%;
margin: 60px auto 0 auto;
padding: 1em;
}
/* pertaining header ------------------------------------ */
header, #main::before {
height: 60px;
}
header {
position: fixed;
top: 0;
width: 100%;
margin: auto;
background: linear-gradient(180deg, #91C1CC, #468795);
border-bottom: 1px solid black;
}
header div {
width: 1200px;
margin: 0 auto;
padding: 0;
}
header div p {
margin-top: 16px;
margin-left: 1000px;
font-family: Whitehall, Verdana, Geneva, sans-serif;
font-size: 2.5em;
color: white;
}
/* pertaining footer ------------------------------------ */
#container::after {
content: "";
display: block;
}
footer, #main::after {
height: 40px;
}
footer {
position: fixed;
bottom: 0;
width: 100%;
margin: auto;
background: linear-gradient(0, #91C1CC, #468795);
border-top: 1px solid black;
}
footer div {
width: 1200px;
margin: auto;
padding: 1em;
}
#departments {
margin: 0;
padding: 0 1em;
margin-top: -8px;
margin-left: -22px;
font-size: 85%;
}
#departments a {
margin-right: 3em;
color: black;
}
#departments a:link, #departments a:visited {
text-decoration: none;
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test</title>
</head>
<body>
<div id="container">
<header>
<div>
<p>Main title</p>
</div>
</header>
<div id="main">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam sit amet sem quam. Donec vehicula sed urna a tempor. Mauris facilisis malesuada varius. In ut dapibus lorem. Nullam iaculis tortor eget mauris sagittis, sed elementum mi semper. Aliquam faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat. Duis elementum, nulla at pulvinar pharetra, ligula purus scelerisque libero, quis fermentum dui ante blandit dui.
Vivamus bibendum, mauris vitae hendrerit aliquam, metus quam elementum est, sed viverra enim ipsum nec dui. Duis rutrum, eros a dignissim laoreet, enim justo feugiat massa, et pretium ex ligula et nunc. Praesent quis quam scelerisque, hendrerit diam in, suscipit felis. Curabitur iaculis congue augue, sit amet rutrum nisi luctus id. Praesent ac massa quis ligula fermentum laoreet. Vivamus sed faucibus elit. Aliquam faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam sit amet sem quam. Donec vehicula sed urna a tempor. Mauris facilisis malesuada varius. In ut dapibus lorem. Nullam iaculis tortor eget mauris sagittis, sed elementum mi semper. Aliquam faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat. Duis elementum, nulla at pulvinar pharetra, ligula purus scelerisque libero, quis fermentum dui ante blandit dui.
Vivamus bibendum, mauris vitae hendrerit aliquam, metus quam elementum est, sed viverra enim ipsum nec dui. Duis rutrum, eros a dignissim laoreet, enim justo feugiat massa, et pretium ex ligula et nunc. Praesent quis quam scelerisque, hendrerit diam in, suscipit felis. Curabitur iaculis congue augue, sit amet rutrum nisi luctus id. Praesent ac massa quis ligula fermentum laoreet. Vivamus sed faucibus elit. Aliquam faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam sit amet sem quam. Donec vehicula sed urna a tempor. Mauris facilisis malesuada varius. In ut dapibus lorem. Nullam iaculis tortor eget mauris sagittis, sed elementum mi semper. Aliquam faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat. Duis elementum, nulla at pulvinar pharetra, ligula purus scelerisque libero, quis fermentum dui ante blandit dui.
Vivamus bibendum, mauris vitae hendrerit aliquam, metus quam elementum est, sed viverra enim ipsum nec dui. Duis rutrum, eros a dignissim laoreet, enim justo feugiat massa, et pretium ex ligula et nunc. Praesent quis quam scelerisque, hendrerit diam in, suscipit felis. Curabitur iaculis congue augue, sit amet rutrum nisi luctus id. Praesent ac massa quis ligula fermentum laoreet. Vivamus sed faucibus elit. Aliquam faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam sit amet sem quam. Donec vehicula sed urna a tempor. Mauris facilisis malesuada varius. In ut dapibus lorem. Nullam iaculis tortor eget mauris sagittis, sed elementum mi semper. Aliquam faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat. Duis elementum, nulla at pulvinar pharetra, ligula purus scelerisque libero, quis fermentum dui ante blandit dui.
Vivamus bibendum, mauris vitae hendrerit aliquam, metus quam elementum est, sed viverra enim ipsum nec dui. Duis rutrum, eros a dignissim laoreet, enim justo feugiat massa, et pretium ex ligula et nunc. Praesent quis quam scelerisque, hendrerit diam in, suscipit felis. Curabitur iaculis congue augue, sit amet rutrum nisi luctus id. Praesent ac massa quis ligula fermentum laoreet. Vivamus sed faucibus elit. Aliquam faucibus vel felis quis tempus. Pellentesque cursus risus at venenatis volutpat.
</p>
</div>
<footer>
<div>
<p id="departments">
◼ About
◼ Contact
◼ Sitemap
</p>
</div>
</footer>
</div>
</body>
</html>
As you've set the header as position: fixed; you could add left: 0; to the header and it will force it to the left. Then you don't need to set the width.

CSS: When flex row wraps, how to keep scrollable column from being pushed down below its container's fold?

In a fixed-height container, I have a flexbox (.main) with flex-direction: row and flex-wrap: wrap. At a wide screen size, I'd like its children — an image (.image-column), and a long amount of text (.text-column) — to be columns, in which the image remains static and the text scrolls. So far, so good. When sized down past the columns' min widths, I'd like them to wrap and stack. This all works, but here's the problem: when they wrap and stack, the scrollable text is offset by the min-height of the .image-column above it, such that when you scroll down to the bottom of the text, the scrollbar disappears offscreen rather than remaining within its container. But if you adjust the height to account for this offset, the .text-column is squished in the unwrapped state.
The two conflicting elements seem to be:
.image-column's min-height: 200px — but without this, the image doesn't show up at all when wrapped
.text-column's height: 100% — but without this, the text doesn't scroll
I've tried .text-column with height: calc(100% - 200px) — this fixes the offset when stacked, but creates unnecessary whitespace when in columns, and I'd prefer to avoid such specificity anyway
I'd like to figure out a solution with CSS only and no media queries, since this container may be in a multi-column layout with other containers. I'm willing to use flex, grid, float, or any other arcane layout trick.
Has anyone else experienced this issue with flex row wrapping and scrolling?
(You can run the code snippet below to see the layout wrapped, and press Full Page to see the layout in its wide 2-column state.)
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 40px;
padding: 40px;
background: #f6f6f6;
font-family: sans-serif; font-size: 120%; line-height: 1.5; color: #111;
}
.container {
height: 600px;
min-width: 300px;
max-width: 900px;
width: 100%;
display: flex;
flex-direction: column;
background-color: white;
border-radius: 10px;
overflow: hidden; /* don't scroll */
border: 1px solid #ccc;
}
.header {
border-bottom: 1px solid #ccc;
padding: 20px;
}
.main {
flex: 1 1 auto; /* fills remainder of height */
display: flex;
flex-direction: row;
flex-wrap: wrap; /* wrap after elements reach min-width / flex-basis */
overflow: hidden; /* don't scroll */
}
.image-column {
min-height: 200px;
flex: 1 1 300px; /* column width, min for wrapping */
background-image: url('https://images.unsplash.com/photo-1641361784653-73767ccfdf60?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHx0b3BpYy1mZWVkfDM0fDZzTVZqVExTa2VRfHxlbnwwfHx8fA%3D%3D&auto=format&fit=crop&w=900&q=60');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
.text-column {
height: 100%;
flex: 2 1 420px; /* column width, min for wrapping */
overflow: auto; /* scroll */
padding: 20px;
}
.footer {
border-top: 1px solid #ccc;
padding: 20px;
}
<div class="container">
<div class="header">Header</div>
<div class="main">
<div class="image-column"></div>
<div class="text-column">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla varius enim eu justo posuere, a laoreet urna sodales. Mauris ac porta lorem, id malesuada ipsum. In ac ipsum sapien. Nunc nisi tellus, auctor vitae placerat sit amet, posuere id velit. In semper ex placerat purus sollicitudin, at aliquet metus viverra. Nam malesuada vel tellus malesuada fermentum. Curabitur iaculis vel lacus nec scelerisque. Praesent feugiat ac augue bibendum facilisis. Curabitur dapibus malesuada magna sit amet vehicula. Fusce ipsum eros, consectetur in sodales ac, lacinia at purus. Quisque laoreet justo et semper luctus. Nam ligula orci, ultricies et enim non, elementum rutrum massa. Aenean cursus lacus in magna hendrerit, in fermentum ex porttitor. Integer elementum, enim sit amet vehicula mollis, diam tortor congue massa, eget accumsan nulla arcu a leo. Maecenas convallis placerat magna, vitae lacinia mi ullamcorper quis. Etiam congue aliquet dolor eget dignissim. Donec malesuada laoreet nibh, sit amet tristique lacus facilisis nec. Quisque sit amet enim ac lectus bibendum laoreet. Pellentesque eleifend urna eget ultricies commodo. Nulla ex sapien, accumsan sit amet est vitae, pretium sollicitudin metus. Nullam finibus, ipsum id tincidunt tristique, diam tortor pellentesque orci, non rutrum turpis arcu ultricies eros. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla varius enim eu justo posuere, a laoreet urna sodales. Mauris ac porta lorem, id malesuada ipsum. In ac ipsum sapien. Nunc nisi tellus, auctor vitae placerat sit amet, posuere id velit. In semper ex placerat purus sollicitudin, at aliquet metus viverra. Nam malesuada vel tellus malesuada fermentum. Curabitur iaculis vel lacus nec scelerisque. Praesent feugiat ac augue bibendum facilisis. Curabitur dapibus malesuada magna sit amet vehicula. Fusce ipsum eros, consectetur in sodales ac, lacinia at purus. Quisque laoreet justo et semper luctus. Nam ligula orci, ultricies et enim non, elementum rutrum massa. Aenean cursus lacus in magna hendrerit, in fermentum ex porttitor. Integer elementum, enim sit amet vehicula mollis, diam tortor congue massa, eget accumsan nulla arcu a leo. Maecenas convallis placerat magna, vitae lacinia mi ullamcorper quis. Etiam congue aliquet dolor eget dignissim. Donec malesuada laoreet nibh, sit amet tristique lacus facilisis nec. Quisque sit amet enim ac lectus bibendum laoreet. Pellentesque eleifend urna eget ultricies commodo. Nulla ex sapien, accumsan sit amet est vitae, pretium sollicitudin metus. Nullam finibus, ipsum id tincidunt tristique, diam tortor pellentesque orci, non rutrum turpis arcu ultricies eros.</p>
</div>
</div>
<div class="footer">Footer</div>
</div>
I've found a solution to my own question.
Grid has a similar way of wrapping columns, using repeat's auto-fit with a minmax for each column in which the min is a fixed width.
.main {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
overflow: hidden; /* don't scroll */
}
Using this approach, when the columns wrap, the first column's min-height no longer offsets the second column and its scrollbar out of the container, as it did with flex row wrap.
The only small drawback is that the grid's two columns must be of equal width in order for the wrapping to work. For my uses, this is acceptable.
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 40px;
padding: 40px;
background: #f6f6f6;
font-family: sans-serif; font-size: 120%; line-height: 1.5; color: #111;
}
.container {
height: 600px;
min-width: 300px;
max-width: 900px;
width: 100%;
display: flex;
flex-direction: column;
background-color: white;
border-radius: 10px;
overflow: hidden; /* don't scroll */
border: 1px solid #ccc;
}
.header {
border-bottom: 1px solid #ccc;
padding: 20px;
}
.main {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
overflow: hidden; /* don't scroll */
}
.image-column {
min-height: 200px;
background-image: url('https://images.unsplash.com/photo-1641361784653-73767ccfdf60?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHx0b3BpYy1mZWVkfDM0fDZzTVZqVExTa2VRfHxlbnwwfHx8fA%3D%3D&auto=format&fit=crop&w=900&q=60');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
.text-column {
overflow: auto; /* scroll */
padding: 20px;
}
.footer {
border-top: 1px solid #ccc;
padding: 20px;
}
<div class="container">
<div class="header">Header</div>
<div class="main">
<div class="image-column"></div>
<div class="text-column">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla varius enim eu justo posuere, a laoreet urna sodales. Mauris ac porta lorem, id malesuada ipsum. In ac ipsum sapien. Nunc nisi tellus, auctor vitae placerat sit amet, posuere id velit. In semper ex placerat purus sollicitudin, at aliquet metus viverra. Nam malesuada vel tellus malesuada fermentum. Curabitur iaculis vel lacus nec scelerisque. Praesent feugiat ac augue bibendum facilisis. Curabitur dapibus malesuada magna sit amet vehicula. Fusce ipsum eros, consectetur in sodales ac, lacinia at purus. Quisque laoreet justo et semper luctus. Nam ligula orci, ultricies et enim non, elementum rutrum massa. Aenean cursus lacus in magna hendrerit, in fermentum ex porttitor. Integer elementum, enim sit amet vehicula mollis, diam tortor congue massa, eget accumsan nulla arcu a leo. Maecenas convallis placerat magna, vitae lacinia mi ullamcorper quis. Etiam congue aliquet dolor eget dignissim. Donec malesuada laoreet nibh, sit amet tristique lacus facilisis nec. Quisque sit amet enim ac lectus bibendum laoreet. Pellentesque eleifend urna eget ultricies commodo. Nulla ex sapien, accumsan sit amet est vitae, pretium sollicitudin metus. Nullam finibus, ipsum id tincidunt tristique, diam tortor pellentesque orci, non rutrum turpis arcu ultricies eros. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla varius enim eu justo posuere, a laoreet urna sodales. Mauris ac porta lorem, id malesuada ipsum. In ac ipsum sapien. Nunc nisi tellus, auctor vitae placerat sit amet, posuere id velit. In semper ex placerat purus sollicitudin, at aliquet metus viverra. Nam malesuada vel tellus malesuada fermentum. Curabitur iaculis vel lacus nec scelerisque. Praesent feugiat ac augue bibendum facilisis. Curabitur dapibus malesuada magna sit amet vehicula. Fusce ipsum eros, consectetur in sodales ac, lacinia at purus. Quisque laoreet justo et semper luctus. Nam ligula orci, ultricies et enim non, elementum rutrum massa. Aenean cursus lacus in magna hendrerit, in fermentum ex porttitor. Integer elementum, enim sit amet vehicula mollis, diam tortor congue massa, eget accumsan nulla arcu a leo. Maecenas convallis placerat magna, vitae lacinia mi ullamcorper quis. Etiam congue aliquet dolor eget dignissim. Donec malesuada laoreet nibh, sit amet tristique lacus facilisis nec. Quisque sit amet enim ac lectus bibendum laoreet. Pellentesque eleifend urna eget ultricies commodo. Nulla ex sapien, accumsan sit amet est vitae, pretium sollicitudin metus. Nullam finibus, ipsum id tincidunt tristique, diam tortor pellentesque orci, non rutrum turpis arcu ultricies eros.</p>
</div>
</div>
<div class="footer">Footer</div>
</div>
(You can run the code snippet below to see the layout wrapped, and press Full Page to see the layout in its wide 2-column state.)
try setting the height of .text-column to 260px
.text-column {
height: 260px;
flex: 2 1 420px; /* column width, min for wrapping */
overflow: auto; /* don't scroll */
}

What in my CS code is making my right column drop down when with smaller screen size?

When I resize my window to 1280 x 720 or below I just realized I'm getting some behavior I do not want. The right column (.right class) is getting "bumped down" below when I resize my window
What is it in my CSS code (or not in the code) that's causing this? I have a feeling that I'm missing a very important concept here. :)
Here is what happens to the right column on smaller screens: http://s11.postimg.org/vp9c7o3dv/css.png
And here is the faulty code:
http://codepen.io/cosmonaut/pen/yyvZjZ?editors=110
html {
background: url(http://s16.postimg.org/k5re12691/bg_radium.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
body {
width: 95%;
font-family: courier;
font-size: 15px;
color: #E7DFC2;
margin-left: 30px;
}
.container {
width: 90%;
margin: 10px auto;
background-color: #273E23;
opacity: 0.97;
margin-top: 25px;
}
.header {
text-align:center;
font-size: 40px;
padding: 1em;
border-bottom: 1px solid gray; /* Temporary. */
background-color: #273E23;
}
.header p {
font-size: 25px;
padding: 0px;
margin: 0px;
background-color: #273E23;
}
.header img {
padding: 0px;
margin: 0px;
width: 200px;
height: 200px;
}
.menu {
text-align: center;
}
.menu ul {
}
.menu ul li {
margin: 0 20px;
padding: 0;
list-style-type: none;
display: inline-block;
}
.menu ul li a {
text-decoration: none;
background-color: #273E23;
color: #D3B474;
}
.left {
float: left;
width: 160px;
margin: 0;
padding: 1em;
}
.right {
padding: 1em;
float: right;
width: 860px;
background-color: #273E23;;
}
.right p {
background-color: #273E23;
}
.footer {
clear: both;
margin: 0px;
padding: .5em;
text-align: center;
background-color: #273E23;
}
<!DOCTYPE html>
<html>
<head>
<link type="text/css" rel="stylesheet" href="stylesheet_v2.css"/>
<title>Radium Recordings</title>
</head>
<body>
<div class="container">
<div class="header">
<img src="http://s11.postimg.org/z08mz7o9f/radium4.png">
</div>
<div class="menu">
<ul>
<li>Home</li>
<li>Releases</li>
<li>Tours</li>
<li>Contact</li>
</ul>
</div>
<div class="left"><p>Hi, I'm the left side. Not sure if I'm even going to keep this column. Lorem Ipsum added:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris lacinia tellus vel nunc accumsan maximus. Pellentesque justo sem, condimentum non lectus sed, consequat dignissim eros. Integer id ante lectus. Nam id nisi dui. Curabitur euismod volutpat accumsan. Donec pellentesque metus eleifend, imperdiet arcu lacinia, convallis est. Curabitur porta interdum vehicula. Fusce mollis quam et ex venenatis, eget luctus risus pellentesque.</p>
</div>
<div class="right">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris lacinia tellus vel nunc accumsan maximus. Pellentesque justo sem, condimentum non lectus sed, consequat dignissim eros. Integer id ante lectus. Nam id nisi dui. Curabitur euismod volutpat accumsan. Donec pellentesque metus eleifend, imperdiet arcu lacinia, convallis est. Curabitur porta interdum vehicula. Fusce mollis quam et ex venenatis, eget luctus risus pellentesque.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris lacinia tellus vel nunc accumsan maximus. Pellentesque justo sem, condimentum non lectus sed, consequat dignissim eros. Integer id ante lectus. Nam id nisi dui. Curabitur euismod volutpat accumsan. Donec pellentesque metus eleifend, imperdiet arcu lacinia, convallis est. Curabitur porta interdum vehicula. Fusce mollis quam et ex venenatis, eget luctus risus pellentesque.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris lacinia tellus vel nunc accumsan maximus. Pellentesque justo sem, condimentum non lectus sed, consequat dignissim eros. Integer id ante lectus. Nam id nisi dui. Curabitur euismod volutpat accumsan. Donec pellentesque metus eleifend, imperdiet arcu lacinia, convallis est. Curabitur porta interdum vehicula. Fusce mollis quam et ex venenatis, eget luctus risus pellentesque.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris lacinia tellus vel nunc accumsan maximus. Pellentesque justo sem, condimentum non lectus sed, consequat dignissim eros. Integer id ante lectus. Nam id nisi dui. Curabitur euismod volutpat accumsan. Donec pellentesque metus eleifend, imperdiet arcu lacinia, convallis est. Curabitur porta interdum vehicula. Fusce mollis quam et ex venenatis, eget luctus risus pellentesque.</p>
<p>Aliquam convallis nulla commodo convallis scelerisque. Curabitur elementum porttitor purus, posuere tincidunt turpis sagittis et. Proin non nulla vitae velit rutrum egestas id vitae dolor. Mauris placerat nec metus vel ultrices. Integer molestie lobortis eros a dapibus. Pellentesque commodo iaculis magna fringilla rhoncus. Nullam luctus dui elit, nec ornare erat volutpat vitae. Vestibulum nulla velit, porttitor in hendrerit vel, varius sit amet elit. Aliquam erat volutpat.
</p>
</div>
<div class="footer">
<p>P.O. Box 321, Anywhere, USA 31721 | Tel: (888) 888-8888</p>
</div>
</div>
</body>
</html>
Change your column widths to percentages. One example is this Codepen.
I used:
.left {
float: left;
width: 20%;
margin: 0;
padding: 1em;
}
.right {
padding: 1em;
float: right;
width: 67%;
background-color: #273E23;;
}
but you can use any percentages that look right to you.
You have two column in your site. One have class name "left" another have class named "right". Now each of those class have fixed width. So when the screen size goes less than the declared width the 2nd column get down to get it desire size.
If we see the explanation:
.right {
padding: 1em;
float: right;
width: 860px;
background-color: #273E23;
}
.left {
float: left;
width: 160px;
margin: 0;
padding: 1em;
}
Here we can see right class have width of 860px and the left class have width of 160px. Also the right class have a padding of 1em which is 15 in pixel. So if you want to show both of the element in single line then the minimum screen size should be 1050px (860 + 30 + 160). Here 30 is summation of both side padding 15 px.
If you want to do the code in such way that you what ever the screen size is both column should maintain size ratio then instead of using fixed width you should use %. For batter understanding you can check example of #bobdye
On small screen you have not enough space in .container for two columns.
You should set .container width in px, or declare min-width for it, or declare width of left and right columns in %.

how to expand my side bar the length of my content?

my site : http://web.njit.edu/~dp257/boilerplate/website.html#
i want my side bar to go down to the top of the footer or the same length as my content. I so i do not want to use JQuery or anything like that. Im sure it has to be in the CSS should be an easy fixing but im blanking out.
<div id = "wrapper">
<header id="name" align="center">MY IS117 Website</header>
<div id="primary_links" align="center">
<ul>
<li>Menu 1</li>
<li>Menu 2</li>
<li>Menu 3</li>
<li>Menu 4</li>
<li>Menu 5</li>
</ul>
</div>
<div id="content">
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque velit eros, lacinia non mauris at, facilisis iaculis sem. Aenean eu felis elit. Aenean nec sem ac lectus aliquet sagittis eget sit amet urna. Etiam in dignissim nulla. In non nibh pharetra, posuere mi venenatis, consequat ipsum. Quisque dapibus porttitor posuere. Maecenas porttitor nibh sit amet lacinia vehicula. Nullam sit amet urna gravida, gravida leo vel, ultrices ante. Sed accumsan nibh nec erat dapibus, ut ultrices nisi elementum. Praesent in enim at nunc consectetur cursus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Curabitur quis scelerisque ipsum. Quisque vulputate consectetur egestas. Etiam non tincidunt urna.
</p>
<p>
Aenean fringilla sed urna a ultrices. Aliquam non augue in libero venenatis sodales at ut eros. Nunc ac arcu a justo luctus ultricies. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Maecenas sed molestie leo, vel placerat massa. Nullam at eros ac nunc malesuada fermentum nec vel mi. Nulla convallis mattis facilisis. Vivamus urna quam, tincidunt id venenatis in, porttitor quis lectus. Donec eu vehicula quam, sit amet sollicitudin risus. Nullam nec dapibus tortor. Nam in consectetur urna. Aenean enim eros, ullamcorper vitae mauris at, sollicitudin blandit felis. Ut ac odio blandit, sodales tortor sed, aliquam est.
</p>
<p>
Praesent at sagittis augue. Sed libero ipsum, pharetra eget ante nec, laoreet tempor leo. Cras libero magna, mattis in ligula a, rutrum volutpat libero. Morbi tincidunt lectus eget vehicula eleifend. Nullam pulvinar sapien non porttitor pharetra. Fusce porttitor nunc sit amet iaculis rhoncus. Nullam et est vel enim commodo interdum ac vel odio. Duis pretium lorem ante, condimentum laoreet lectus aliquam at. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Praesent ornare dui vel erat hendrerit, commodo tempus eros vehicula. Morbi dapibus est tristique ligula consequat adipiscing. Nulla non massa nibh. Praesent justo quam, eleifend sed blandit eget, pharetra in augue.
</p>
<p>
Vestibulum tincidunt erat at justo adipiscing condimentum. Morbi ante eros, sagittis at augue a, feugiat malesuada quam. Mauris molestie leo a mi accumsan pretium. Vestibulum tempus mi et sagittis convallis. In ac purus porta nisi congue condimentum. Donec augue lectus, eleifend consectetur suscipit sit amet, volutpat sed enim. Quisque eget enim erat. Cras molestie nisi sed leo elementum, et eleifend est sollicitudin. Quisque sed elit at massa tincidunt vehicula sed non leo. Aenean condimentum, purus et consectetur auctor, nunc diam porttitor sapien, rutrum accumsan nisi lectus at ipsum. Duis blandit nulla felis, a dictum odio egestas pretium. Nullam feugiat justo mi, vel pretium mauris posuere vitae. Duis at adipiscing tortor. Morbi laoreet augue vel ullamcorper venenatis.
</p>
<p>
In porttitor orci nec turpis tempus, in faucibus mauris luctus. Aliquam egestas convallis sollicitudin. Sed congue, ante id porttitor tristique, odio purus molestie lectus, id egestas nisl magna vitae felis. Donec imperdiet lectus sem, vel varius sem aliquam vel. Morbi quis leo suscipit, vulputate nisi at, posuere velit. Duis lorem justo, pharetra id mi ut, egestas laoreet dui. Mauris ultricies libero sit amet ligula porttitor, eget sagittis neque ornare. Suspendisse tristique metus nec auctor volutpat.
</p>
</div>
<!-- content -->
<div id="sidebar">
<div id="secondary_links">
<ul>
<li>Menu 1</li>
<li>Menu 2</li>
<li>Menu 3</li>
<li>Menu 4</li>
<li>Menu 5</li>
</ul>
</div>
</div>
<div id="footer">Footer</div>
</div>
<!-- wrapper -->
CSS
#header {
background-color: cyan;
width: 100px;
height: 100px;
padding: 20px;
margin: 30px;
border: 5px solid;
}
#name {
border: 1px solid;
padding-left: 31px;
padding-right: 31px;
margin-left: auto;
margin-right: auto;
}
#wrapper {
width: 898px;
margin-left: auto;
margin-right: auto;
}
#primary_links li {
display: inline;
}
#primary_links {
height: 75px;
line-height: 75px;
border: 1px solid;
}
#primary_links a {
color: black;
}
#secondary_links ul, #primary_links ul {
margin: 0px;
padding: 0px;
}
#secondary_links li {
list-style: none;
/* gets rid of bullets */;
}
#sidebar {
width: 338px;
float: left;
border: 1px solid;
}
#secondary_links {
/*width:340px; temporary
float:right; put in own div fiix prob*/;
}
#footer {
/*margin-left:508px;
margin-right:230px;*/
clear: both;
background-color: green;
}
#content {
width: 508px;
padding-left: 23px;
padding-right: 23px;
border: 1px solid;
float: left;
}
Do you want your sidebar to the right? With the same height as your content? If this is right, you can use a float: right; on your #sidebar. Put your content and your sidebar in a new div, give him a class like: .wrapper. And set a background image on the .wrapper. If the height change the background will change and also the background wil repeat.
.wrapper {
width: 100%;
background: url('yourimage') repeat;
/* float: left; */
overflow: hidden;
}
I hope you understand this. I can also give you a example, if you want.
EDIT: You can use float left, to give the parent div the height of the children. Or you can use overflow: hidden;.
Add a wrap div around #content and #sidebar. I called the div #content-sidebar-wrap.
Add display:table to #content-sidebar-wrap and add display:table-cell to #content and #sidebar.
#content-sidebar-wrap{
display:table;
height:100%;
}
#content {
width: 508px;
padding-left: 23px;
padding-right: 23px;
border: 1px solid;
float: left;
display:table-cell;
}
#sidebar {
width: 338px;
float: left;
border: 1px solid;
height:100%;
display:table-cell;
}
Check it out: http://jsfiddle.net/LHX9Z/
Use:
For #sidebar: clear: right;
For #footer: clear: both;
Afer that your footer go to bottom, and sidebar to right.
An easy way to get this working properly, is just add some huge padding-bottom to .sidebar, and then counter it with the same (but negative) margin-bottom. Just gotta make sure you set the overflow:hidden to the wrapping class. I'd recommend you move both the header and footer outside wrapper.
FIDDLE
just try this now
#wrapper {
background: none repeat scroll 0 0 #B3D4FC;
margin-left: auto;
margin-right: auto;
width: 898px;
}
#primary_links {
background: none repeat scroll 0 0 #FFFFFF;
border: 1px solid;
height: 75px;
line-height: 75px;
}
#name {
background: none repeat scroll 0 0 #FFFFFF;
border: 1px solid;
margin-left: auto;
margin-right: auto;
padding-left: 31px;
padding-right: 31px;
}
#sidebar {
background-color: #ADD8E6;
border: 1px solid;
float: right;
width: 290px;
}

Why won't this element set to `height: 100%` work in this example in IE7?

I set up this fiddle to show how all browsers render the red pieces.
Strangely, IE7 renders that fine (on its own).
However, I have a shadow effect on a new site (that works the same as the red strips) that works on Firefox, Safari & IE8.
I swear I have used this same method countless times before and it has worked in IE7.
Here is how it looks in IE7. The strips don't grow to the correct height (using IE's developer tools showed me that). They are not just not repeating the background image.
(source: alexanderdickson.com)
The site is also available here to view. I am using IE8's compatibility view, which I realise isn't strictly a 1:1 of IE7, but I according to NetRender, this also happens on IE7.
Can someone please kindly tell me what I am doing wrong?
Thanks!
<div id="main">
<p>
Donec laoreet ullamcorper iaculis. Fusce sed dolor vel mi varius dictum. Phasellus vulputate vehicula odio et pulvinar. Cras pulvinar, magna quis cursus tempus; dolor diam tempus magna; a varius magna velit aliquet libero. Donec auctor pulvinar ornare. Fusce fringilla velit fermentum elit ornare quis porttitor justo vestibulum. Sed feugiat leo in tellus elementum venenatis. Praesent enim lacus, luctus ac porta vitae, iaculis eu arcu! Praesent commodo eleifend lacus, non fringilla orci commodo non. Praesent varius adipiscing purus, et accumsan orci porta nec? Cras imperdiet blandit dapibus. Curabitur dolor magna, imperdiet at euismod non, pharetra in turpis. Integer aliquam neque a justo imperdiet fermentum. Aenean et vulputate orci. Aliquam volutpat, sapien sed sollicitudin porta, risus massa gravida nibh; pharetra vulputate nisl orci ac nibh? Fusce vehicula tristique magna ut suscipit. Morbi imperdiet diam quis nibh sagittis consequat.
</p>
<p>
Nunc tempus iaculis justo quis ultrices. Nulla diam orci, euismod sed mattis id, condimentum ac est. Maecenas sodales egestas massa hendrerit ultrices. Fusce ut ante id leo placerat pellentesque. Mauris ante dolor, porta quis blandit vel; tincidunt sed sem. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed dictum, nunc vitae posuere suscipit, leo leo dictum nunc, vel laoreet eros dolor ac lacus. Duis at nibh nec lectus commodo vehicula sit amet sed sem. Sed eu massa orci! Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nullam tellus nibh, lacinia sed imperdiet nec, vestibulum ut nunc. Donec fermentum placerat felis, porta lacinia erat pellentesque vel. In eu ornare ipsum. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
</p>
<p>
Praesent fringilla mattis lobortis? Sed id porttitor massa! Pellentesque sodales felis et lacus tincidunt sit amet adipiscing arcu aliquam. Proin ullamcorper elementum urna nec mollis. Etiam convallis elementum massa in egestas! Ut pharetra mauris nec mi auctor posuere. Fusce a velit quis tellus accumsan blandit et sit amet odio. In hac habitasse platea dictumst. Nullam nunc orci; pulvinar ac lacinia id, tincidunt at dolor. Curabitur facilisis volutpat sagittis. Maecenas luctus rutrum ante et tincidunt. Nulla non dapibus dui. Proin consectetur pellentesque nunc, ac convallis enim venenatis ut. Aliquam a interdum nibh. Curabitur tristique ipsum ornare ante semper eget luctus nulla volutpat. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse non est sem. Nulla sodales, metus sit amet ullamcorper mollis, velit velit tempus odio, at tristique diam lorem non risus. Suspendisse dictum lorem laoreet metus euismod gravida. Nullam dapibus magna nisi.
</p>
<div id="shadow-left"></div>
<div id="shadow-right"></div>
</div>
html {
width: 100%;
height:100%;
}
div#main {
width: 100px;
min-height: 100%;
margin: 0 auto;
position: relative;
}
#shadow-left,
#shadow-right {
width: 30px;
height: 100%;
position: absolute;
top: 0;
background: red;
}
#shadow-left {
left: -30px;
}
#shadow-right {
right: -30px;
}
I'm not sure why you would apply your shadows in this manner though. How I usually do it is have a wider container (including the widths of the left/right shadows) aligned center (in this case, it's your #mainContainer div, then set a y-repeating background (that is the shadow - just a couple of pixels high will do). I will then specify another div within this container, smaller width, center aligned, that will contain all the text.
Edit: Just noticed your fiddle. I think it may not work in this case due to css conflicts, possible from the osCommerce stylesheet? I'll try to look deeper..hmm
EDIT2: Okay I've traced it to this particular code in stylesheet.css
#login-link,
#logout-link {
position: absolute;
bottom: -20px;
right: 50px;
background: #333;
padding: 5px;
text-decoration: none;
-webkit-border-bottom-right-radius: 5px;
-webkit-border-bottom-left-radius: 5px;
-moz-border-radius-bottomright: 5px;
-moz-border-radius-bottomleft: 5px;
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
z-index: 100;
font-weight: bold;
}
Login to GolfBallBusters
It's your absolute positioning of this element that's causing the problem. Removing the styling fixes your shadow problems. :)
EDIT FIX:
This should fix it. Or at least it does on my stripped down version of your site layout.
Change #user and #login-link to the following:
#user {
float: right;
color: #f90;
position: relative; /* addition */
}
#login-link,
#logout-link {
position: absolute;
top: 31px; /* addition */
/*bottom: -20px; REMOVED */
right: 50px;
height: 15px; /* addition */
white-space: nowrap; /* addition */
background: #333;
padding: 5px;
text-decoration: none;
-webkit-border-bottom-right-radius: 5px;
-webkit-border-bottom-left-radius: 5px;
-moz-border-radius-bottomright: 5px;
-moz-border-radius-bottomleft: 5px;
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
z-index: 100;
font-weight: bold;
}
FIX2:
Change
#user-options .bottom-shadow {
display: block;
width: 100%;
height: 7px;
position: absolute;
bottom: -7px;
#bottom: -5px;
left: 0;
background: url(images/layout/shadow-bottom.png) repeat-x;
z-index: 50;
}
TO
.bottom-shadow {
width: 100%;
height: 7px;
margin-top: -10px;
background: url(images/layout/shadow-bottom.png) repeat-x;
}
And your HTML layout should be:
<div id="user-options">
<div id="choose-your-country">
<p>Choose your country > </p>
</div>
<div id="user"></div>
<div id="current-locale">Golf Ball Busters - AU</div>
<br class="clear">
</div>
<div class="bottom-shadow"></div>
Noticed I change bottom-shadow into a div element and moved it out of <div id="user-options">.
try giving #mainContainer height: 100%

Resources