Forum Moderators: not2easy

Message Too Old, No Replies

Adding a border breaks the layout

         

D_Blackwell

5:00 am on May 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This code originated from a thread that got clipped for a url drop, but I've created my own new problem:)

There is a border-bottom for .title, but adding it breaks the layout in the good browsers. (Looks fine in IE.)

What am I failing to understand?

<html>
<head>
<style>
html, body {
margin: 0; padding: 0; font-size: 100%;
}
body {
background-color: #f4f4ff; font: 500 1.2em tahoma, verdana, sans-serif;
}
#wrapper {
width: 60%; background-color: #fff; border-left: .1em solid #ccd;
border-right: .1em solid #ccd; border-bottom: .6em double #ccd; position: absolute; top: 0; left: 20%;
}
#header {
border-bottom: .1em solid #ccd; background-color: #ccd; height: 7em; color: #006;
}
#content {
}
#menu {
float: left; width: 15%; margin: .1em 2% 0 .2em;
}
#content a {
color: #006;
}
#content a:hover {
color: #99c;
}
a.menu {
text-decoration: none; display: block; color: #99c; line-height: 1.2em;
border-bottom: .15em solid #fafafc;
}
a.menu:hover {
background: #f4f4ff; border-bottom: .15em solid #ccd; color: #ccd;
}
a.menu:visited {
color: #88a;
}
.hide {
display: none
}
.title {
font-size: 1.5em; border-bottom: .2em double #ccd; margin-bottom: .6em; width: 60%; color: #006;
}
.subtitle {
font-size: 1.3em; color: #aad;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="header">
LOGO
</div>

<div id="menu">
<a class="menu" href="">link list
</a>
<span class="hide">¦</span>
<a class="menu" href="xx">link list
</a>
<span class="hide">¦</span>
<a class="menu" href="xx">link list
</a>
<span class="hide">¦</span>
<a class="menu" href="xx">link list
</a>
<span class="hide">¦</span>
<a class="menu" href="xx">link list
</a>
<span class="hide">¦</span>
<a class="menu" href="xx">link list
</a>
<span class="hide">¦</span>
<a class="menu" href="xx">link list
</a>
<span class="hide">¦</span>
<a class="menu" href="xx">link list
</a>
<span class="hide">¦</span>
<a class="menu" href="xx">link list
</a>
<span class="hide">¦</span>
</div>
<div id="content">
<div class="title">
title
</div>
<div class="subtitle">
subtitle
</div>
<p>
This is the content. <a href="xx">This is a link</a>. This is yet more content to pad out this box to make it

more believeable. This is yet more content.
</p>
<div class="subtitle">
subtitle
</div>
<p>
This is the content. <a href="xx">This is a link</a>. This is yet more content to pad out this box to make it

more believeable. This is yet more content.
</p>
</div>
</body>
</html>

encyclo

2:20 pm on May 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



By breaking the layout, do you mean that the border on .title runs beneath the menu?

For debugging, I would add the following rule to the stylesheet:

div {border:1px solid red!important;}

and then add

background:#ff0;
to the .title div. You'll see that the title div runs underneath the menu, and the border is taking up all the width. Looks like you need to add something like
margin-left:15%;
to the title div to allow for the floated menu.

D_Blackwell

4:19 pm on May 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Adding a border to .title or .content does show that they are running under the menu. Adding {margin-left: 17%;} does move the border right where I want it.

Why does the text go exactly where I want it, yet borders run under the float? The menu is {float-left}. Shouldn't .content and .title, including their borders, be beside it? I could {float: right;} .content and give it a width, but it doesn't seem like I should have to.

[edit] Hmmm. Dr. Doc would probably soon be sending me here: Floats 9.5 [w3.org] [/edit]

SuzyUK

4:47 pm on May 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It is acting correctly if you were to put a background color on the title div too it would run underneath the menu too. The menu is floating over the top of the title div (except in IE whose float model works differently of course ;)).

The only thing that should actually "move" is the "anonymous" line box and this is what you're seeing.

The margin is the way I would get the effect I wanted too ;)

Suzy

and yes I had that link in this post, but I removed it! hehe...