|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
whats wrong with this css ???
This css looks great in IE, but in netscape, etc. its fubared. the positioning of the #leftcolumn is wayy out in the middle of the page instead of aligned like it should be and the right column is below the left column.
Code:
body {
margin: 0;
padding: 0;
font-size: 12px;
font-family: 'Arial', 'Lucida Grande',
Verdana, Lucida, Geneva, Helvetica,
Arial, sans-serif;
background: #ccc url(/greydusk/images/bgtile.gif) repeat-y 50% 0;
}
#caption {
font-style: italic;
font-weight: bold;
padding-top: 5px;
}
#frame {
width:750px;
margin-right:auto;
margin-left:auto;
padding:0px;
text-align:left;
}
#header {
float: left;
width: 751px;
height: 55px;
background: #ccc url(/greydusk/images/header_back.gif);
}
#leftcolumn {
float: left;
width: 505px;
background:#fff;
margin-top: 0px;
margin-left: 2px;
padding-bottom:20px;
}
#title {
display: block;
font-weight: bold;
font-size: 15px;
}
#date {
float: left;
margin-left: -35px;
font-weight: normal;
color: #9C9C9C;
}
#leftcolumn p {
background: url(/greydusk/images/marker1.gif) no-repeat top left;
text-indent: 50px;
padding-left: 15px;
padding-right: 10px;
margin-top: 35px;
}
#rightcolumn {
float: left;
width: 235px;
margin-left: 5px;
}
#rightcolumn p {
padding-left: 15px;
padding-right: 15px;
}
#menu {
background-color: #000;
width: 751px;
font-size: 14px;
color: #FFF;
}
#menu ul {
list-style: none;
margin: 0 0 0 0;
padding: 0px;
}
#menu li {
float: left;
margin: 0 0 0 0;
padding-right: 15px;
padding-top: 4px;
padding-left: 15px;
padding-bottom: 7px;
}
#menu li a {
padding: 0px;
padding-bottom: 3px;
margin: 0 px;
color: #fff;
text-decoration: none;
}
#menu li a:hover {
border-bottom: 4px solid #7F88DA;
color: #7F88DA;
}
and here is the page. Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<title>test site</title>
<script type="text/javascript"></script>
<style type="text/css" media="all">
@import "/greydusk/css/greydusk.css";
</style>
</head>
<body onload="window.defaultStatus='test-site';" id="test">
<div id="frame">
<div id="header">
<p> </p>
</div>
<div id="menu">
<ul>
<li><a href="blah.htm">home</a></li>
<li><a href="blah.htm">news</a></li>
<li><a href="blah.htm">forums</a></li>
</ul>
</div>
<div id="leftcolumn">
<p><span id="title">Sample news title, hello there!</span>
BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH
BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH
BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH
<span id="date">March 1, 2004 | <a href="blah.com">Comments</a></span></p>
<p><span id="title">Sample news title, hello there!</span>
BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH
BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH
BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH
<span id="date">March 1, 2004 | <a href="blah.com">Comments</a></span></p>
<p><span id="title">Sample news title, hello there!</span>
BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH
BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH
BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH
<span id="date">March 1, 2004 | <a href="blah.com">Comments</a></span></p>
<p><span id="title">Sample news title, hello there!</span>
BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH
BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH
BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH
<span id="date">March 1, 2004 | <a href="blah.com">Comments</a></span></p>
<p><span id="title">Sample news title, hello there!</span>
BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH
BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH
BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH
<span id="date">March 1, 2004 | <a href="blah.com">Comments</a></span></p>
<p><span id="title">Sample news title, hello there!</span>
BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH
BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH
BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH
<span id="date">March 1, 2004 | <a href="blah.com">Comments</a></span></p>
<p><span id="title">Sample news title, hello there!</span>
BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH
BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH
BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH
<span id="date">March 1, 2004 | <a href="blah.com">Comments</a></span></p>
</div>
<div id="rightcolumn">
<p>BLAH BLAH BLAH BLAH</p>
<p>BLAH BLAH BLAH BLAH</p>
<p>BLAH BLAH BLAH BLAH</p>
<p>BLAH BLAH BLAH BLAH</p>
<p>BLAH BLAH BLAH BLAH</p>
<p>BLAH BLAH BLAH BLAH</p>
</div>
</div>
</body>
</html>
thanks in advance! this thing is frustrating me to no end! and i just no it's a simple 1 or 2 lines i need to change. =(
__________________
-Sotonin |
|
#2
|
||||
|
||||
|
Ok, it's pretty simple. IE really screws up on floats. The fix actually fixes two things. First, a float does not actually occupy real estate in its containing block. IE mistakingly expands the container to enclose a float. Moz/NS, correctly, does not, so there must be content to expand the box. You'll notice that in NS, the menu does not have a black background. That's because it has zero height.
Then there is the problem you wrote about—the leftcolumn not being on the left. This is because it follows a float element (the menu list) is is correctly abutted on the left. The simple fix is to add a clearing element immediately after the menu list. To test, I used <br style="clear: both" />. See /*PIE*/ for some excellant articles on positioning, and the float model in particular. As a side note, #title and #date should be classes, not ids. cheers, gary
__________________
There are those who manage to build a web site without knowing what they're doing; thereby proving to themselves they do, indeed, know what they're doing. Ask a better question, get a better answer. |
|
#3
|
||||
|
||||
|
you can fix it with placing a <br style="clear:both;" /> after the unordered list in the div element #menu.
but you got several problem with the rest of the markup. first you use the same id more than once, id's are unique you can only use the same id once in a document, use class instead. class="date", and in css .date instead of id="date" and #date don't use a span to make a title use an appropriate h[1-6]tag. just an example of what you can do: (this also fixes some problems that occured in opera) Code:
<h2>Sample news title, hello there!</h2>
<p>
BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH
BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH
BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH BLAH
</p>
<p class="date">March 1, 2004 | <a href="blah.com">Comments</a></p>
and the css for this:
#leftcolumn h2 {
margin-top: 35px;
font-size: 15px;
margin-bottom:0;
padding-bottom:0;
padding-left: 15px;
}
#leftcolumn .date {
color: #9C9C9C;
}
#leftcolumn p {
padding-left: 15px;
padding-right: 10px;
margin-top: 0px;
margin-bottom:0;
}
I aslo noted that you use doctype xhtml1.1, remember that xhtml1.1 should be sent as application/xhtml+xml http://www.w3.org/TR/xhtml-media-types/#summary this might give you some trouble with non-conforming browsers http://www.greytower.net/en/archive...tmlcontent.html Last edited by Akh : March 2nd, 2004 at 07:39 AM. |
|
#4
|
|||
|
|||
|
Thanks for that trick, it worked like a charm!.
But now i'm plagued with yet another problem. You somewhat touched on it by saying the menu wasn't black. But i tried adding height: value and it didn't fix anything. So i changed the background-color to black on the li. This somewhat worked. now each list item is black. but the list itself does not extend the full intended width. I tried setting UL to black, etc. nothing seems to work. the list just wont extend all the way in netscape. any more advice would be great. thanks!! |
|
#5
|
||||
|
||||
|
The <br style="clear: both" /> element must be immediately after the </ul>, and within the menu div. No other messing with those style rules is needed.
cheers, gary ps. As Akh said, xhtml 1.1 should be delivered as application/xhtml+xml. If you do that, though, IE goes stupid. Use doctype xhtml 1.0. gt |
|
#6
|
|||
|
|||
|
Thanks, you're the man!.
As far as the header, I'm not really even sure what all that garbage means to be honest, what should it say as the header? I don't want it to freak out in IE or anything like that. |
|
#7
|
||||
|
||||
|
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type"
content="text/html; charset=ISO-8859-1" />
<title>test site</title>
<style type="text/css" media="all">
@import "/greydusk/css/greydusk.css";
</style>
</head>
cheers, gary |
![]() |
| Viewing: Dev Shed Forums > Web Design > CSS Help > whats wrong with this css ??? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|