Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB 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 October 17th, 2011, 09:43 PM
Authorized User
 
Join Date: Apr 2010
Posts: 15
Thanks: 8
Thanked 0 Times in 0 Posts
Smile CSS - float property

Hello Imar, and anyone else who reads this
I have a question regarding CSS.
On pages 81-82, step 8 of the TryItOut, there are some CSS rules.
What really confuses me is the float property.
Here what I understood after consulting this website: www.w3schools.com:

You can float elements to the right or the left. Any element that follows the floated element will flow around the floated element on the other side.
For example, if I float an image to the left, any text or other elements following it will flow around it to the right. And if I float an image to the right, any text or other elements following it will flow around it to the left.

So far so good, but that's not in keeping with the book's example, and I'll explain.
On page 84, book says "You need to tell the Sidebar to float as well; if you leave it out, it will be placed at the left of the page, right where it was before you applied the CSS."
The thing is, it's correct, the MainContent element has float:left, but still without telling the Sidebar to float, it wouldn't float, namely, it wouldn't flow around it to the right.
But that's so not in keeping with what I typed above.

I've played around with things, and if float:right is given to the MainContent element instead of float:left, and the float property is deleted completely for the Sidebar element, the behavior will be as expected, namely, the Sidebar element will move to the left of MainContent.
So why in the book's example, both elements, MainContent and Sidebar must have the float:left property, in order to receive the desired behavior, whereas according to the definition of the float property, only MainContent should have it?

Thanks for any help guys...
 
Old October 17th, 2011, 11:39 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Confusing; I agree. It could very well be in a bug in the browsers I tested this on. If I recall correctly, it worked without the second float in IE, but not in Firefox (or the other way around, not sure).

I agree you wouldn't need it when you look at the CSS specs.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
float not working mister_mister CSS Cascading Style Sheets 1 March 11th, 2008 05:00 PM
Help With CSS "Align" Property TheSchwa Other Programming Languages 1 October 22nd, 2007 03:38 PM
IE6 and CSS "right" property? kend CSS Cascading Style Sheets 2 January 11th, 2006 02:19 PM
CSS Float Display Problem socoolbrewster CSS Cascading Style Sheets 12 October 20th, 2005 07:22 AM
CSS Float error socoolbrewster CSS Cascading Style Sheets 3 July 18th, 2005 09:25 AM





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