Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-18-2012, 02:39 PM   PM User | #1
paddyfields
Regular Coder

 
Join Date: Dec 2010
Location: London
Posts: 278
Thanks: 60
Thanked 11 Times in 11 Posts
paddyfields is an unknown quantity at this point
Smile fluid layout with fixed position

Hi there.

Any help with this would be amazing, I've created a simple code below for what I am trying to do, but I can't get it to behave how I wish.

I want...
  • #topmenu and #sidemenu to be fixed when scrolling (which works)
  • #extracontent to have a fixed width and be floated to the right of the page (which works)
  • #middlecontent should resize to the width between #sidemenu and #extracontent when the browser is resized horizontally.

Is that last point possible? If so does anyone have any advice how I can acheive this? At the moment it pushes down the #extracontent and I'm pretty sure the fixed width will be sitting on top of some of #middlecontent

Any help would be great

Code:
<!DOCTYPE html>

	<head>
		
		<title>sweet layout</title>
	
		<style type="text/css" media="screen">
		
			#container {
			width: 100%;
			height: 1000px;
			}
			
			#topmenu {
			position: fixed;
			top: 0px;
			left: 0px;
			height:30px;
			width: 100%;
			background:red;		
			}
			
			#sidemenu {
			position:fixed;
			top: 30px;
			left: 0px;
			width: 200px;
			height: 100%;
			background: blue;		
			}
			
			
			#middlecontent {
			float: left;
			height: 100%;
			background: yellow;
			width: 100%;
			}
			
			
			#extracontent {
			float: right;
			width: 300px;
			height: 100%;	
			background: orange;	
			}
			
			
		</style>
		
	
	</head>
	
	<body>
	
		<div id="container">
	
			<div id="topmenu">fixed</div>
			
			<div id="sidemenu">fixed</div>
			
			<div id="middlecontent"></div>
			
			<div id="extracontent"></div>
	
		</div>
	
	</body>
	
</html>

Last edited by paddyfields; 12-18-2012 at 02:44 PM..
paddyfields is offline   Reply With Quote
Old 12-18-2012, 03:25 PM   PM User | #2
Excavator
Master Coder


 
Excavator's Avatar
 
Join Date: Dec 2006
Location: Alaska
Posts: 9,410
Thanks: 22
Thanked 1,765 Times in 1,749 Posts
Excavator has a spectacular aura aboutExcavator has a spectacular aura aboutExcavator has a spectacular aura about
Goodmorning paddyfields,
Instead of specifying a width on you #middlecontent, just margin the sides to allow for the elements that sit there.

Like this -
Code:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>sweet layout</title>
<style type="text/css" media="screen">
html, body {
	height: 100%;
	margin: 0;
}
#container {
	width: 100%;
	overflow: auto; /*to clear floats*/
}
#topmenu {
	position: fixed;
	top: 0px;
	left: 0px;
	height: 30px;
	width: 100%;
	background: #f00;
}
#sidemenu {
	position: fixed;
	top: 30px;
	left: 0px;
	width: 200px;
	height: 100%;
	background: #00f;
}
#extracontent {
	height: 1800px;
	width: 300px;
	margin: 30px 0 0;
	float: right;
	background: #f90;
}
#middlecontent {
	height: 1800px;
	margin: 30px 300px 0 200px;
	background: #ff0;
}
</style>
</head>
<body>
    <div id="container">
        <div id="topmenu">fixed</div>
        <div id="sidemenu">fixed</div>
        <div id="extracontent">scrolls</div>
        <div id="middlecontent">scrolls</div>
    <!--end container--></div>
</body>
</html>
Loosely based on this example.
__________________
Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad
Excavator is offline   Reply With Quote
Users who have thanked Excavator for this post:
paddyfields (12-18-2012)
Old 12-18-2012, 04:20 PM   PM User | #3
paddyfields
Regular Coder

 
Join Date: Dec 2010
Location: London
Posts: 278
Thanks: 60
Thanked 11 Times in 11 Posts
paddyfields is an unknown quantity at this point
Ah excellent, thank you. The margins on the #middlecontent make a lot of sense now you've laid it out for me.

Merry Christmas!
paddyfields is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:32 AM.


Advertisement
Log in to turn off these ads.