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 03-06-2013, 05:48 AM   PM User | #1
Windbrand
New Coder

 
Join Date: Sep 2011
Posts: 44
Thanks: 4
Thanked 0 Times in 0 Posts
Windbrand is an unknown quantity at this point
How do I set up three columns like this?

Does anyone know how I would get a page set up like this?


http://i.imgur.com/cxLmGkl.png

Code:
.pagecontainer {
margin-top:50px;
padding-left:50px;
padding-right:50px;
position:relative;
width:80%;
height:450px;
}
.leftcolumn {
width: 250px;
}
.middlecolumn {
margin-left:250px;
padding-left:25px;
margin-right:300px;
padding-right:25px;
float:left;
display:inline;
}
.verticalimage {
float:right;
display:inline;
width:300px;
}
Code:
<div class="pagecontainer">

    <div class="leftcolumn">text <br> text <br> text</div>

    <div class="middlecolumn">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sit amet lorem velit. Nullam et metus eget nunc egestas laoreet et quis ligula. Vivamus lobortis sodales pulvinar. Nunc malesuada pretium ornare. Aliquam ut erat at magna pellentesque elementum. Fusce facilisis lorem et tortor euismod bibendum.</div>

    <img class="rightverticalimage" src="picture1.png"/>

</div>
- A page container with dynamic width of 80% of browser window
- Inside it are 3 sections:
- Left text column of 250px width, 50px margin to the left against pagecontainer
- Right column is an image of 300px width, 50px margin to right against pagecontainer
- Middle column is whatever space that's left in the middle, dynamic width

I've tried various combinations of floats and display types (block, inline-block, etc) but can't get it to work. The vertical image keeps getting bumped below the middle column of text.

Thanks.

Last edited by Windbrand; 03-06-2013 at 06:14 AM..
Windbrand is offline   Reply With Quote
Old 03-06-2013, 05:55 AM   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
Hello Windbrand,
I have a demo that shows that here.
__________________
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
Old 03-06-2013, 06:05 AM   PM User | #3
Windbrand
New Coder

 
Join Date: Sep 2011
Posts: 44
Thanks: 4
Thanked 0 Times in 0 Posts
Windbrand is an unknown quantity at this point
I checked that demo but the width of the container is not dynamic as I resize the browser window. I need the container to stretch in width when the browser window has high resolution, but the left/right columns to be fixed in width.
Windbrand is offline   Reply With Quote
Old 03-06-2013, 08:15 AM   PM User | #4
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
Quote:
Originally Posted by Windbrand View Post
I checked that demo but the width of the container is not dynamic as I resize the browser window. I need the container to stretch in width when the browser window has high resolution, but the left/right columns to be fixed in width.


Try making this change highlighted in red -
Code:
#container {
	/*width: 1000px;*/
width: 80%;
	margin: 30px auto 900px;
	background: #999;
	overflow: auto;
	font-size: 0.8em;
}
To explain further, remove or comment out that width: 1000px; that sets #container to a fixed width.
Put in your 80% width with this line - width: 80%;
__________________
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

Last edited by Excavator; 03-06-2013 at 08:19 AM..
Excavator is offline   Reply With Quote
Old 03-06-2013, 11:57 AM   PM User | #5
coothead
Senior Coder

 
coothead's Avatar
 
Join Date: Jan 2004
Location: chertsey, a small town 25 miles south west of london, england.
Posts: 1,551
Thanks: 0
Thanked 195 Times in 191 Posts
coothead will become famous soon enough
Hi there Windbrand,

check out the attachment, to see a possible solution.

coothead
Attached Files
File Type: zip windbrand.zip (2.5 KB, 9 views)
coothead is offline   Reply With Quote
Old 03-06-2013, 04:20 PM   PM User | #6
Windbrand
New Coder

 
Join Date: Sep 2011
Posts: 44
Thanks: 4
Thanked 0 Times in 0 Posts
Windbrand is an unknown quantity at this point
Thanks I've tried that on my page but it won't work still. It's really weird your test page works perfectly, I pretty much copied over the code on mine but it still won't work...
Here is my code:

Code:
.pagecontainer {
	overflow-y:auto;
	overflow-x:hidden;
	background: transparent url(pagecontentoverlay.png);
	width:80%;
        min-width:800px;
        padding:30px 0;
	height:500px;
	margin: 0 auto;
	font-size:12px;
	color:#999;
}

.pagecontainer>div{
	padding-left:50px;
	padding-right:50px;
	position:relative;
}

.middlecolumn {
	padding:10px;
    margin:0 300px 0 273px;
}

.rightverticalimage {
	float:right;
    width:200px;
    padding:10px;
}

.leftcolumn{
	float:left;
    width:250px;
    padding:10px;
	font-size:16px;
	text-align:left;
	border-right:thin solid #fff;
}
Code:
<div class="pagecontainer">

	<div id="lisztwork3page">
		
		<div class="leftcolumn">
			<a href="#lisztpage" class="link_expandContainer" onclick="return false">Back to main</a>
			<p>
			<font size="-1">
			<a href="#lisztwork1page">Hungarian Rhapsody No.2</a>
			<p>
			<a href="#lisztwork2page">La Campanella</a>
			<p>
			<b>| Transcendental Etude No.4 |</b>
			<p>
			<a href="#lisztwork4page">Transcendental Etude No.5</a>
			<p>
			<a href="#lisztwork5page">Transcendental Etude No.8</a>
			</font>
			<p>
		</div>
		
		<div class="middlecolumn">
			<b>Transcendental Etude No.4 "Mazeppa"</b>
			<br>
			<br>
			<br>
			Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum luctus justo eget lorem porta iaculis. 
			Fusce dictum ipsum in turpis pellentesque pellentesque. Pellentesque facilisis, nulla sed suscipit dignissim, 
			lacus sem dictum ligula, vel facilisis neque mi eu purus. Sed quis erat velit, sit amet volutpat urna. Aliquam erat volutpat. 
			Cras purus diam, volutpat porttitor blandit sit amet, tempor et risus. Aenean pharetra nisi quis nisi vestibulum ut molestie 
			lacus aliquam. Curabitur vitae nisi orci, quis dapibus mauris. Sed leo magna, facilisis eget auctor non, pharetra ac mauris. 
			Vestibulum massa felis, tincidunt ac tristique ut, tincidunt nec tortor.
		</div>
		<br>
		<br>
		<br>
		
		<img class="rightverticalimage" src="http://api.ning.com/files/GTfAIob4Rdv8a6DlFSc9WysVp-JgbpduT7uYIE8j1ikuGsgC-29xobgn8H0TmQ9BToHy0hy9EZThN*qhBF9Kqs0MJs0O-XQJ/musicnotes.jpg" alt=""/>

	</div>

</div>
I have no idea what's wrong :/
I have uploaded the test files.
(btw just using a test image for the right column)
Attached Files
File Type: zip test.zip (4.4 KB, 8 views)
Windbrand is offline   Reply With Quote
Old 03-06-2013, 05:42 PM   PM User | #7
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
Look at what happens when you change the order in the markup, remember - floats come first.

Code:
<!DOCTYPE HTML>
<html xmlns:fb="http://ogp.me/ns/fb#">
<head>

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


</head>

<body>
<div class="pagecontainer">

	<div id="lisztwork3page">
		
		<div class="leftcolumn">
			<a href="#lisztpage" class="link_expandContainer" onclick="return false">Back to main</a>
			<p>
			<font size="-1">
			<a href="#lisztwork1page">Hungarian Rhapsody No.2</a>
			<p>
			<a href="#lisztwork2page">La Campanella</a>
			<p>
			<b>| Transcendental Etude No.4 |</b>
			<p>
			<a href="#lisztwork4page">Transcendental Etude No.5</a>
			<p>
			<a href="#lisztwork5page">Transcendental Etude No.8</a>
			</font>
			<p>
		</div>
		
		<img class="rightverticalimage" src="http://api.ning.com/files/GTfAIob4Rdv8a6DlFSc9WysVp-JgbpduT7uYIE8j1ikuGsgC-29xobgn8H0TmQ9BToHy0hy9EZThN*qhBF9Kqs0MJs0O-XQJ/musicnotes.jpg" alt=""/>
		
		<div class="middlecolumn">
			<b>Transcendental Etude No.4 "Mazeppa"</b>
			<br>
			<br>
			<br>
			Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum luctus justo eget lorem porta iaculis. 
			Fusce dictum ipsum in turpis pellentesque pellentesque. Pellentesque facilisis, nulla sed suscipit dignissim, 
			lacus sem dictum ligula, vel facilisis neque mi eu purus. Sed quis erat velit, sit amet volutpat urna. Aliquam erat volutpat. 
			Cras purus diam, volutpat porttitor blandit sit amet, tempor et risus. Aenean pharetra nisi quis nisi vestibulum ut molestie 
			lacus aliquam. Curabitur vitae nisi orci, quis dapibus mauris. Sed leo magna, facilisis eget auctor non, pharetra ac mauris. 
			Vestibulum massa felis, tincidunt ac tristique ut, tincidunt nec tortor.
		</div>
		<br>
		<br>
		<br>
		

	</div>

</div>
</body>
</html>
...
The next step would be to validate both your CSS and your Markup. Have a look at the links in my signature about validation.


.
__________________
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:
Windbrand (03-07-2013)
Old 03-06-2013, 07:31 PM   PM User | #8
coothead
Senior Coder

 
coothead's Avatar
 
Join Date: Jan 2004
Location: chertsey, a small town 25 miles south west of london, england.
Posts: 1,551
Thanks: 0
Thanked 195 Times in 191 Posts
coothead will become famous soon enough
Hi there Windbrand,

when I try to open your attachment with "WinZip", I get this message...
Cannot open file: it does not appear to be a valid archive.
I would have added yours to mine, not the other way round.

coothead
Attached Files
File Type: zip windbrand-v2.zip (2.9 KB, 6 views)
coothead is offline   Reply With Quote
Users who have thanked coothead for this post:
Windbrand (03-07-2013)
Old 03-06-2013, 10:07 PM   PM User | #9
Obsidian
New Coder

 
Join Date: Feb 2013
Posts: 28
Thanks: 1
Thanked 4 Times in 4 Posts
Obsidian is an unknown quantity at this point
I could suggest using min-width for this setting. The sample below is flexible to the screen size, however when the screen shrunken the boxes will not shrink below 200px. I use a similar column layout for my site (you're welcome to check out the site's code, it's linked from my profile) to ensure no blank spaces when the screen is shrunken and that everything stays in place. It will be very difficult to have the middle section automatically adjust with the rest of the page based on percentage without the other two columns falling under it, because of the float value and the space available.

Code:
<html>
<head>
<style>
#box1 {
float: left;
background: red;
width: 40%;
min-width: 200px;
margin-right: 25px;
}
#box2 {
background: black;
float: left;
width: 40%;
min-width: 200px;
}
</style>
</head>
<body>
<div id="box1">text</div>
<div id="box2">text</div>

</body>
</html>
I hope this helps.
Obsidian is offline   Reply With Quote
Users who have thanked Obsidian for this post:
Windbrand (03-07-2013)
Old 03-07-2013, 02:08 PM   PM User | #10
Windbrand
New Coder

 
Join Date: Sep 2011
Posts: 44
Thanks: 4
Thanked 0 Times in 0 Posts
Windbrand is an unknown quantity at this point
Thanks!
Excavator is right, switching the order of the float elements in the html worked.
Windbrand is offline   Reply With Quote
Reply

Bookmarks

Tags
column, display, image, inline

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 07:44 PM.


Advertisement
Log in to turn off these ads.