Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > CSS > CSS Cascading Style Sheets
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
CSS Cascading Style Sheets All issues relating to Cascading Style Sheets (CSS).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the CSS Cascading Style Sheets section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 25th, 2007, 02:45 AM
Authorized User
 
Join Date: Mar 2007
Location: Kuala Lumpur, Wilayah Persekutuan, Malaysia.
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to kennethjaysone Send a message via Yahoo to kennethjaysone
Default 2-column layout

I am following a tutorial in which i have constructed a XHTML markup which i have pasted below.

<body class="lookingPage">
<div id="wrapper">
<div id="masthead">
<div id="navContainer">
<div id="navigation">[list]
<li id="lookingPage"><a href="#">Looking</a></li>
<li id="gazingPage"><a href="#">Gazing</a></li>
<li id="watchingPage"><a href="#">Watching</a></li>
</ul>
</div>
</div>
</div>

<div id="content">
<div id="maincontent">
<h1>This is the page title</h1>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi commodo, ipsum sed pharetra gravida, orci magna rhoncus neque, id pulvinar odio lorem non turpis. Nullam sit amet enim. Suspendisse id velit vitae ligula volutpat condimentum. Aliquam erat volutpat. Sed quis velit. Nulla facilisi. Nulla libero. Vivamus pharetra posuere sapien. Nam consectetuer. Sed aliquam, nunc eget euismod ullamcorper, lectus nunc ullamcorper orci, fermentum bibendum enim nibh eget ipsum.</p>
<p>Donec porttitor ligula eu dolor. Maecenas vitae nulla consequat libero cursus venenatis. Nam magna enim, accumsan eu, blandit sed, blandit a, eros.Quisque facilisis erat a dui. Nam malesuada ornare dolor. Cras gravida, diam sit amet rhoncus ornare, erat elit consectetuer erat, id egestas pede nibh eget odio. Proin tincidunt, velit vel porta elementum, magna diam molestie sapien, non aliquet massa pede eu diam. Aliquam iaculis. Fusce et ipsum et nulla tristique facilisis.</p>
<p>Donec eget sem sit amet ligula viverra gravida. Etiam vehicula urna vel turpis. Suspendisse sagittis ante a urna. Morbi a est quis orci consequat rutrum. Nullam egestas feugiat felis. Integer adipiscing semper ligula. Nunc molestie, nisl sit amet cursus convallis, sapien lectus pretium metus, vitae pretium enim wisi id lectus. Donec vestibulum. Etiam vel nibh. Nulla facilisi. Mauris pharetra. Donec augue. Fusce ultrices, neque id dignissim ultrices, tellus mauris dictum elit, vel lacinia enim metus eu nunc.Proin at eros non eros adipiscing mollis. Donec semper turpis sed diam.</p>
<p>Sed consequat ligula nec tortor. Integer eget sem. Ut vitae enim eu est vehicula gravida. Morbi ipsum ipsum, porta nec, tempor id, auctor vitae, purus. Pellentesque neque. Nulla luctus erat vitae libero. Integer nec enim. Phasellus aliquam enim et tortor. Quisque aliquet, quam elementum condimentum feugiat, tellus odio consectetuer wisi, vel nonummy sem neque in elit.</p>
</div>

<div id="sidebar">
<h1>Sidebar Title</h1>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi commodo, ipsum sed pharetra gravida, orci magna rhoncus neque, id pulvinar odio lorem non turpis. Nullam sit amet enim. Suspendisse id velit vitae ligula volutpat condimentum. Aliquam erat volutpat. Sed quis velit.Sed aliquam, nunc eget euismod ullamcorper, lectus nunc ullamcorper orci, fermentum bibendum enim nibh eget ipsum.</p>
<p>Donec porttitor ligula eu dolor. Maecenas vitae nulla consequat libero cursus venenatis. Nulla facilisi. Nulla libero. Vivamus pharetra posuere sapien. Nam consectetuer. Cras gravida, diam sit amet rhoncus ornare, erat elit consectetuer erat, id egestas pede nibh eget odio. Proin tincidunt, velit vel porta elementum, magna diam molestie sapien, non aliquet massa pede eu diam. Aliquam iaculis. Fusce et ipsum et nulla tristique facilisis.</p>
</div>

<div class="seperator">
</div>

</div>

</div>

</body>


And the CSS that i have written for this markup is below.

/*------defaults-------*/

* {
margin: 0;
padding: 0;
}

body {
background: #1b4b7d url(assets/page-background.jpg) repeat-x;
color: #102c4a;
padding-bottom: 40px;
}

/* --------- 2. structure --------- */

#wrapper {
margin: 0 auto;
width: 740px;
border-left: 2px solid #047bc4;
border-right: 2px solid #047bc4;
border-bottom: 2px solid #047bc4;
}

#masthead {
height: 189px;
background: url(assets1/masthead-background.jpg) no-repeat;
}

#content {
background: #a4b7cb url(assets1/content-background.jpg) repeat-x;
padding: 40px 14px 40px 0;
}

#sidebar {
float: right;
width: 199px;
padding-top: 31px;
}

#maincontent {
float: right;
width: 490px;
padding-left: 10px;
margin-left: 10px;
border-left: 1px solid #7c8a99;
}

.seperator {
clear: both;
height:0;
}

My question is, why does the browser display the #sidebar div first when in the markup it is the #maincontent that came first? When we write XHTML markup, isn't is suppose to display it on the left to rigth top to bottom method (exactly the way we read from left to right and to follow the next line of text).

I understand that i have floated both the #sidebar and #maincontent to the right, but isn't that suppose to make the #maincontent move to the right side
of the #content div and also make the #sidebar to appear underneath the #maincontent and also on the right side (inside the #content div)

Thank you all in advance for all your thoughts and views.

Reply With Quote
  #2 (permalink)  
Old December 25th, 2007, 11:51 AM
Friend of Wrox
Points: 1,315, Level: 14
Points: 1,315, Level: 14 Points: 1,315, Level: 14 Points: 1,315, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: , , .
Posts: 425
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Quote:
quote:When we write XHTML markup, isn't is suppose to display it on the left to rigth top to bottom method (exactly the way we read from left to right and to follow the next line of text).
HTML will display block-level elements like DIV one under the other in the order they occur in the source. The X makes no difference.


Quote:
quote:I understand that i have floated both the #sidebar and #maincontent to the right, but isn't that suppose to make the #maincontent move to the right side
of the #content div and also make the #sidebar to appear underneath the #maincontent and also on the right side (inside the #content div)
If you float several elements that come after eachother in the source to the right, the one that is first in the source will float as far right as it can. The next one will do the same, meaning that if there's room for it it will end up inside the first floated box, to the left of it if you will. Any additional floated boxes will do likewise until there is no more room. The first box that doesn't fit alongside the others will position itself under the first box and start a new row of floated boxes. Note: if all the boxes aren't the same hight, they can get stuck on eachother and not go all the way to the right when a new row should start.

This all is much the same as align=left|right used with images or tables works in HTML.

If CSS couldn't change the way HTML displays, what would be the point of using it? ;)

--
http://yupapa.com
Reply With Quote
  #3 (permalink)  
Old January 12th, 2008, 06:44 AM
Authorized User
 
Join Date: Jul 2007
Location: , , .
Posts: 13
Thanks: 0
Thanked 1 Time in 1 Post
Default

You are totally right meow, I agree with you..

-----------------------------------------------------------------------------------------------------------------------------------------------------------------
http://coco4info.com
http://supportinglinks.com/
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
IE 6 & 7 issues in two column layout Cyber Shiva BOOK: CSS Instant Results 0 July 7th, 2008 03:47 AM
3 column layout acevision7 BOOK: Professional CSS: Cascading Style Sheets for Web Design 0 February 24th, 2008 11:13 PM
Center two column layout nloding CSS Cascading Style Sheets 1 June 21st, 2006 12:11 PM
three-column layout help DSteven CSS Cascading Style Sheets 8 December 28th, 2004 10:02 AM
layout adflynn Java GUI 0 November 9th, 2004 06:33 AM



All times are GMT -4. The time now is 05:29 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.