100% left sidebar, content right..help

I’m trying to do a BASIC layout with a 100% left sidebar that I wan’t to take up the whole browser window height wise. Then my content will go in the big area on the right.

How I want it to appear is so when you scroll, only the content scrolls. So essentially the left sidebar is “standing still” (fixed).

Just looking to see if this is set up correctly, because I was getting some nasty page errors. My page wont scroll on the right. The content just goes down and disappears.

EDIT: Ah noticed I had the #holder (right) side set to fixed. I took that off but now half of the content on the right, is behind the left sidebar. But if I up the resolution on my browser, the content all goes to the right. So I have some big styling issues here. If anyone could help I would love you forever!

Thanks

HTML:

<!DOCTYPE HTML>
<html>
<head>
<title>Webdesigncove</title>

<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body>
<div id="leftBar"> <!-- Begin Sidebar div-->

	<h1 class="logo">Web<font color="#ffa800">design</font>cove</h1>
	<br />
	
<ul id="navigation">
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Resources</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">Forums</a></li>
</ul>
<font color="white"><center><i>(Underlines on lists are cool)</i></center></font>


</div> <!-- End Side bar div-->



<div id="holder"> <!-- Begin Content Div -->

	<article> <!-- This is a blog post, or 'article' -->
		<h1 class="postTitle">Article Title, This Article Rules</h1>
		<img src="articleimage.jpg" width="490" height="200" alt="article image"> 
        <p>This is a preview text on what the current article is about. Since we will be using Wordpress, the more tag will be highly used.</p>
	</article> <!-- Ending the blog post -->
	
	<article> <!-- This is a blog post, or 'article' -->
		<h1 class="postTitle">Article Title, This Article Rules</h1>
		<img src="articleimage.jpg" width="490" height="200" alt="article image"> 
        <p>This is a preview text on what the current article is about. Since we will be using Wordpress, the more tag will be highly used.</p>
	</article> <!-- Ending the blog post -->

<article> <!-- This is a blog post, or 'article' -->
		<h1 class="postTitle">Article Title, This Article Rules</h1>
		<img src="articleimage.jpg" width="490" height="200" alt="article image"> 
        <p>This is a preview text on what the current article is about. Since we will be using Wordpress, the more tag will be highly used.</p>
	</article> <!-- Ending the blog post -->
	
	<article> <!-- This is a blog post, or 'article' -->
		<h1 class="postTitle">Article Title, This Article Rules</h1>
		<img src="articleimage.jpg" width="490" height="200" alt="article image"> 
        <p>This is a preview text on what the current article is about. Since we will be using Wordpress, the more tag will be highly used.</p>
	</article> <!-- Ending the blog post -->
	
	<article> <!-- This is a blog post, or 'article' -->
		<h1 class="postTitle">Article Title, This Article Rules</h1>
		<img src="articleimage.jpg" width="490" height="200" alt="article image"> 
        <p>This is a preview text on what the current article is about. Since we will be using Wordpress, the more tag will be highly used.</p>
	</article> <!-- Ending the blog post -->

</div> 
<!-- End Content Div--> 




</body>
</html>

CSS:

@charset "utf-8";
/* CSS Document */

* {
	padding: 0px;
	margin: 0px;
}

body {
	background: #f5f5f5;
	font-family: Helvetica, Arial, sans-serif;
}

#leftBar {
	background-color: #333333;
	top: 0px;
	bottom: 0px;
	left: 0px;
	position: fixed;
	width: 262px;
	 box-shadow: 6px 2px 8px rgba(0, 0, 0, 0.80);
    -moz-box-shadow: 6px 2px 8px rgba(0, 0, 0, 0.80);
    -webkit-box-shadow: 6px 2px 8px rgba(0, 0, 0, 0.80);
	}

#holder {
	width: 700px;
	margin-left: 263px;
	padding-left: 50px;
	margin-top: 10px;
	height: 100%;
	float: right;
	position: fixed;
}

@font-face {
	font-family: BEBAS;
	src: url("http://webdesigncove.com/fonts/BEBAS___.ttf")
}

h1.logo {
	font-size: 26px;
	font-style: normal;
	font-weight: normal;
	letter-spacing: normal;
	text-transform: uppercase;
	line-height: 1.2em;
	letter-spacing: -3px;
	color: white;
	text-align: center;
	padding-top: 10px;
}

h1.postTitle {
	font-family: BEBAS, Helvetica, Verdana, Sans-Serif;
	}
	
p {
	font-family: Helvetica, Arial, sans-serif;
	font-size: 15px;
	font-style: normal;
	font-weight: normal;
	letter-spacing: normal;
	line-height: 1.45em;
}

#navigation {
	padding: 0;
	margin: 0;
	text-align: center;
}

#navigation li {
	list-style-type: none;
}

#navigation a:link {
	font-family: BEBAS, Helvetica, Verdana, Sans-Serif;
	font-size: 24px;
	color: white;
}

#navigation a:visited {
	color: white;
}

#navigation a:hover {
	color: #ffa800;
}



When I take position:fixed off of #holder it works for me.

I just saw your edit where you mentioned position fixed. In Chrome, the content does not float to the right, which is what you want right? So I am guessing that in other browsers it does. I haven’t tried it yet, with your code, but rather than float right on the content, how about float left on the side bar? That way the content just flushes up next to the side bar and stays there?

Hi,

Don’t float the main content at all just give it a margin-lef to clear the sidebar and also remove the height:100% otherwise it can never grow.

Like this:


<!DOCTYPE HTML>
<html>
<head>
<title>Webdesigncove</title>
<link href="style.css" rel="stylesheet" type="text/css">
<style>
@charset "utf-8";
/* CSS Document */
@font-face {
	font-family: BEBAS;
	src: url("http://webdesigncove.com/fonts/BEBAS___.ttf")
}
html, body, table{
	margin: 0;
	padding: 0;
	font-size: 100%;
} 
object, iframe,blockquote,
h1, h2, h3, h4, h5, h6, p, 
dl, dt, dd, ol, ul, fieldset, 
form, legend, table, caption, th, td {
	margin: 0;
	padding: 0;
	border:none;
}
body {
	background: #f5f5f5;
	font-family: Helvetica, Arial, sans-serif;
}
#leftBar {
	background-color: #333333;
	top: 0px;
	bottom: 0px;
	left: 0px;
	position: fixed;
	width: 262px;
	box-shadow: 6px 2px 8px rgba(0, 0, 0, 0.80);
	-moz-box-shadow: 6px 2px 8px rgba(0, 0, 0, 0.80);
	-webkit-box-shadow: 6px 2px 8px rgba(0, 0, 0, 0.80);
	overflow:auto;/* must have scrollbar if content is outside viewport*/
}
#holder {
	margin-left: 263px;
	padding-left: 50px;
	margin-top: 10px;
	zoom:1.0;/* ie6 and 7*/
}
h1.logo {
	font-size: 26px;
	font-style: normal;
	font-weight: normal;
	letter-spacing: normal;
	text-transform: uppercase;
	line-height: 1.2em;
	letter-spacing: -3px;
	color: white;
	text-align: center;
	padding-top: 10px;
}
h1.postTitle { font-family: BEBAS, Helvetica, Verdana, Sans-Serif; }
p {
	font-size: 15px;
	font-style: normal;
	font-weight: normal;
	letter-spacing: normal;
	line-height: 1.45em;
}
#navigation {
	text-align: center;
 list-style-type: none;
}
#navigation a:link {
	font-family: BEBAS, Helvetica, Verdana, Sans-Serif;
	font-size: 24px;
	color: white;
}
#navigation a:visited { color: white; }
#navigation a:hover { color: #ffa800; }
</style>
</head>

<body>
<div id="leftBar"> <!-- Begin Sidebar div-->
		<h1 class="logo">Web<font color="#ffa800">design</font>cove</h1>
		<ul id="navigation">
				<li><a href="#">Home</a></li>
				<li><a href="#">About</a></li>
				<li><a href="#">Resources</a></li>
				<li><a href="#">Contact</a></li>
				<li><a href="#">Forums</a></li>
		</ul>
		<!-- (Underlines on lists are an abomination. Only links should be underlined) --> 
</div>
<!-- End Side bar div-->
<div id="holder"> <!-- Begin Content Div -->
		<article> <!-- This is a blog post, or 'article' -->
				<h1 class="postTitle">Article Title, This Article Rules</h1>
				<p><img src="articleimage.jpg" width="490" height="200" alt="article image"></p>
				<p>This is a preview text on what the current article is about. Since we will be using Wordpress, the more tag will be highly used.</p>
		</article>
		<!-- Ending the blog post -->
		
		<article> <!-- This is a blog post, or 'article' -->
				<h1 class="postTitle">Article Title, This Article Rules</h1>
				<p><img src="articleimage.jpg" width="490" height="200" alt="article image"></p>
				<p>This is a preview text on what the current article is about. Since we will be using Wordpress, the more tag will be highly used.</p>
		</article>
		<!-- Ending the blog post -->
		
		<article> <!-- This is a blog post, or 'article' -->
				<h1 class="postTitle">Article Title, This Article Rules</h1>
				<p><img src="articleimage.jpg" width="490" height="200" alt="article image"></p>
				<p>This is a preview text on what the current article is about. Since we will be using Wordpress, the more tag will be highly used.</p>
		</article>
		<!-- Ending the blog post -->
		
		<article> <!-- This is a blog post, or 'article' -->
				<h1 class="postTitle">Article Title, This Article Rules</h1>
				<p><img src="articleimage.jpg" width="490" height="200" alt="article image"></p>
				<p>This is a preview text on what the current article is about. Since we will be using Wordpress, the more tag will be highly used.</p>
		</article>
		<!-- Ending the blog post -->
		
		<article> <!-- This is a blog post, or 'article' -->
				<h1 class="postTitle">Article Title, This Article Rules</h1>
				<p><img src="articleimage.jpg" width="490" height="200" alt="article image"></p>
				<p>This is a preview text on what the current article is about. Since we will be using Wordpress, the more tag will be highly used.</p>
		</article>
		<!-- Ending the blog post --> 
</div>
<!-- End Content Div-->
</body>
</html>

Remember to declare your html 5 elements as display:block and to add the shiv for IE or it will likely break.

You’ve jumped into the furure with html5 yet you jumped back into last century when you added font tags and center tags lol. Never use them again :slight_smile:

Position:fixed isn’t supported in IE6 so you may want to make the sidebar position:absolute for IE6 and it can scroll away with the content.

LOL I know, I was just trying messing around seeing if I could get a good logo look with just HTML/CSS. I’ll be taking the font tags out later.

Thanks Paul, that helped a ton!

-Chris

Sorry for the bump, Paul.

That fixed the scroll problem, but once I put the images back in, the page looks fine scaled to size. But if I set my browser to full screen all the content in the holder goes to the far right of the page. It does’nt do this though, when the images AREN’T in place.

Any clues on how to fix that?

Uploaded a live version so you can see: http://webdesigncove.com/test/

Thanks again for your help!

Hi,

You are still floating the holder to the right and you have also given it a width and a height which makes no sense.

Remove all three.


#holder{
float:none;
width:auto;
height:auto;
}

If you need to limit the width of the internal elements then apply a width to the inner elements as required (or create an inner wrapper).

Ah I was still linking to the old style sheet, my bad! On a new diet, makes me not think straight!

Thanks Paul

SIGH I won’t even say it…

Wow, welcome to 1997.

comment placements that can trip rendering bugs in IE and FF… comments that the allegedly semantic new tags SHOULD be making pointless or if you just used meaningful class/id names on them would mean you didn’t need comments in the first place – at which point why use that HTML 5 idiocy?

Though as to you’re “problem” – I’d advise AGAINST trying to fix the header and the menu – while it might “look cool” the screen gets too short for the content and it becomes an accessibility disaster – which is why you almost never see that effect on real websites!

Hell, in terms of reliability and stability you’d be better off with framesets – which is a bit like saying that compared to a new car you’d be better off with a Reliant Robin.

This is important. Not everyone has a large screen. If the items in your sidebar are taller than approx 600px tall then someone is not going to be able to see everything in there, because they won’t be able to scroll it!! If it’s taller than 900px then even I, with a 17" laptop, can’t see it either!

Though an overflow box on the right could give a similar effect without the sidebar problem…

There’s nothing to say. Every browser and his grandma understands that.

And you can tell the validator to pretend it’s
<!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”>

or

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN”
http://www.w3.org/TR/html4/strict.dtd”>

or whatever you want.

Yes I already offered that :slight_smile:


#leftBar {
	background-color: #333333;
	[B]top: 0px;
	bottom: 0px;[/B]
	left: 0px;
	position: fixed;
	width: 262px;
	box-shadow: 6px 2px 8px rgba(0, 0, 0, 0.80);
	-moz-box-shadow: 6px 2px 8px rgba(0, 0, 0, 0.80);
	-webkit-box-shadow: 6px 2px 8px rgba(0, 0, 0, 0.80);
	[B]overflow:auto;/* must have scrollbar if content is outside viewport*/[/B]
}

Wow, welcome to 1997.

Yes I felt the same way and commented in the code I gave:


<!-- (Underlines on lists are an abomination. Only links should be underlined) --> 

I should have mentioned both points directly though rather than my subtle approach.

Is something wrong with the Doctype?

Scroll up I already stated the reason for using that

I read about this HTML 5 idiocy on Sitepoint, so I thought it would be neat to try. Those idiots!

Ah true…didn’t even think about that. I just figured not too many people were using 8 inch screens with a 800x600 resolution LOL. Sarcasm aside, so an overflow box on the left navigation (like Paul OB posted) would just add a scroll bar TO the nav IF the user had a screen that couldn’t fit all the text in it?

Sarcasm aside, so an overflow box on the left navigation (like Paul OB posted) would just add a scroll bar TO the nav IF the user had a screen that couldn’t fit all the text in it?

My idea was, the right side would be the overflow box. But you can do it on the left as Paul has it.

If you have a majority of users with a “tall” screen, the only scrollbar they’ll see is for the box on the right… which gives the same illusion of a “fixed” left side.

For those with a lower screen rez setting (apparently there are people who deliberately set this low to increase font size… apparently unaware that they could just increase font size via desktop and browser settings), there will be 2 scrollbars: if the left side navigation is longer/taller than their screen, they get the regular “page” scrollbar all normal pages (like this one) give you. A separate scrollbar would be inside the right-side overflow box. This might be slightly fugly but it would allow everyone to scroll whatever they need.

Hm, yeah, Paul’s would be nicer re looks because the left side’s scrollbar wouldn’t be right next to the main “page” scrollbar. And again if your left side is 100% tall, only users with “short” screens even get a scrollbar on the left side.

Is something wrong with the Doctype?

No. Crusty doesn’t like it because it’s not one that tells the validator to be your harsh mistress (and to do you any good, the validator ought to be a freaking nun with a beating stick), however you are always free to tell validators to validate your document as if you used a Strict doctype. You’ll get a “doctype override” warning and the rest is gravy.