Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 25th, 2007, 02:45 AM
Authorized User
 
Join Date: Mar 2007
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.

 
Old December 25th, 2007, 11:51 AM
Friend of Wrox
 
Join Date: Jun 2003
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
 
Old January 12th, 2008, 06:44 AM
Authorized User
 
Join Date: Jul 2007
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/





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.