Internet Marketing Business Forum


Internet Marketing Business Forum » MAIN FORUMS » Web Design & Programming » What's wrong with this CSS Code?
Web Design & Programming Building websites, coding scripts or developing apps? html, css, javascripts, ajax, php, asp, java, c+, C++ and other geeky info is here.

Reply
 
LinkBack Thread Tools Display Modes
Old 08-01-2009, 02:09 PM   #1 (permalink)
 Steve's Avatar
 
Status: Junior Member
Join Date: Jul 2009
Posts: 8
Steve is on a distinguished road
Default What's wrong with this CSS Code?

I'm trying to use "float" to get a sidebar. This code is supposed to allow for a -18em left margin on a 17 em sidebar that is floated to the right with the content to floated to the left with 20em padding. This should allow the sidebar to remain to the right without dropping down below the content.

But it doesn't work. What have I done wrong with this code?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type"content ="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<style type="text/css">
#content {
float:left;
padding: 0 20em 4em 3em;
background: #AAAAAA
}
#sidebar {
float: right;
width: 17em
margin: 0em 0em 4em -18em;
background: #888888
}
</style>
</head>
<body>
<DIV id="content">content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content content </DIV>
<div id="sidebar">sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar sidebar</div>

</body>
</html>
Problem solved. The best answer saw far is from Kaat. Putting in the missing semi-colons fixed the problem. But there is an error in her reply. There is no need to set the width. This would ruin the effect of being about to resize the window without the sidebar being misplaced
Payneless:

I should have thought about percentages. That makes it much simpler. I've made the below changes, but had to be add <p> and </p> to the text and then be more specific with "#content p" and "#sidebar p" to get margins to work within the divs. Why would the margin sendings not work when nested within the "#content" declarations?

#content p {
margin: 1em 1em 1em 1em;
}
#sidebar p {
margin: 1em 1em 1em 1em
}
#content {
float:left;
width: 70%;
background: #AAAAAA;
padding 1em 1em 1em 1em;
}
#sidebar {
float: right;
width: 30%;
background: #888888;
padding 1em 1em 1em 1em;
}
Steve is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Reply
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -4. The time now is 09:18 AM.
Powered by vBulletin® Version 3.7.0 Beta 6
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.


Nav Item BG