 |
BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3  | This is the forum to discuss the Wrox book Beginning CSS: Cascading Style Sheets for Web Design by Richard York; ISBN: 9780764576423 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 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
|
|
|
|

December 4th, 2005, 01:34 PM
|
|
Authorized User
|
|
Join Date: Nov 2005
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
List of questions from 100% CSS Beginner
Last week I finished studding through "CSS for Web Design". Yesterday I put myself together a little exercise for practice and to try making all this knowledge start to be useful. I find myself now with some questions that I am currently unable, or to lazy or afraid of paper cuts, to resolve. I have pasted the html and css below preceded by a list of my questions.
I have been using an example site referred to in another thread although I canât remember the name of it. It says school registration and is steel blue.
1. Does anyone know of a resource of exercises to practice CSS, or possible some relatively simple CSS web sites to attempt cloning for practice?
2. How do I {clear: left} the navigation list in IE?
3. How do I center and remove the space between the navigation list and the other entities to make it look like one.
4. Also, what am I missing to make the article, content, and product divs behave properly in IE?
5. Do I have IE7 applide correctly?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 strict//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<style type="text/css">
body {
background: rgb(116, 163, 201);
color: rgb(192, 214, 231);
font-family: sans-serif;
margin: 0;
padding: 0;
}
h1, h6 {
margin: 0;
}
div#container {
position: relative;
min-height: 400px;
border: 1px solid rgb(91, 147, 191);
background: rgb(66, 123, 170);
}
div#first-column,
div#third-column {
position: absolute;
top: 0;
bottom: 0;
border: 1px solid rgb(91, 147, 191);
background: steelblue;
width: 200px;
margin: 3px;
}
div#first-column {
left: 0;
}
div#third-column {
right: 0;
}
div#content {
margin: 3px 208px 3px 208px;
background: rgb(57, 107, 149);
border: 1px solid rgb(91, 147, 191);
}
div#header,
div#footer {
background: rgb(66, 123, 170);
padding: 3px;
}
</style>
<!--[if lt IE 7]>
<style type='text/css'>
div#container {
height: 400px; /* height behaves like min-height in Explorer */
}
div#first-column,
div#third-column {
height: expression(document.getElementById('container').of fsetHeight - 10); /* offsetHeight is the real height, not the value of the height property */
}
</style>
<![endif]-->
</head>
<body>
<div id='header'>
<h1>Header</h1>
</div>
<div id='container'>
<div id='first-column'>
<ul id='mainnav'>
<li><a href=''>Home</a></li>
<li><a href=''>Class Registration</a></li>
<li><a href=''>Contact Us</a></li>
</ul>
</div>
<div id='content'>
Text in the content column.
</div>
<div id='third-column'>
Text in the third column.
</div>
</div>
<div id='footer'>
<h6>Footer</h6>
</div>
</body>
</html>
|
|

December 4th, 2005, 01:54 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
|
|
> 1. Does anyone know of a resource of exercises to practice CSS, or possible some relatively simple CSS web sites to attempt cloning for practice?
Go to any site you like, save the page using the Save Page As feature of your browser (that'll get you the images and what not), then start from scratch taking only the content (text and images) to markup a new document. Do your best to make it look identical to the original page. I've done this with a few sites before, including this forum. I typically do this in Firefox, with the original site open in one tab and the replication in another, that let's you tab back and forth quickly to do comparisons.
> 2. How do I {clear: left} the navigation list in IE?
I'm not sure what you mean by this, there are no floats used in that layout.
> 3. How do I center and remove the space between the navigation list and the other entities to make it look like one.
Again I'm not too clear on what you're trying to do. I assume you want to remove default spacing from the list? You can do that with the following rule:
ul#mainnav {
list-style: none;
margin: 0;
padding: 0;
}
> 4. Also, what am I missing to make the article, content, and product divs behave properly in IE?
I get the same output in IE that I get in Firefox. What are you seeing? Link to a screenshot for me, or a URL.
> 5. Do I have IE7 applide correctly?
This example doesn't use Dean Edwards's IE7 JavaScript, it uses conditional comments to single out Internet Explorer 6 and older, and applies MS-propritary expressions to simulate using the top and bottom offset properties to imply height.
http://msdn.microsoft.com/workshop/a...omment_ovw.asp
http://msdn.microsoft.com/workshop/a...iew/recalc.asp
HTH!
Regards,
Rich
--
[ http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design
|
|

December 4th, 2005, 02:53 PM
|
|
Authorized User
|
|
Join Date: Nov 2005
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Good Griff!!!!
I posted the wrong code. I posted the example I had open. This code should make a little more sence.
Also, here are my original questions clearified. They should be more clear with the proper code. Thanks for the quick response too!
1. Does anyone know of a resource of exercises to practice CSS, or possible some relatively simple CSS web sites to attempt cloning for practice, do you know of any good examples of CSS? I have trouble finding 100% CSS. I have a few in mind though.
2. How do I {clear: left} the navigation list in IE, in other words how do I make it horizontal?
3. How do I center and remove the space between the navigation list and the other entities to make it look like one.
4. Also, what am I missing to make the article, content, and product divs behave properly in IE?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 strict//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Logo</title>
</head>
<!--[if lt IE 7]>
<script src="/ie7.9/ie7-standard-p. js" type="text/javascript">
</script>
<![endif]-->
<style type="text/css">
body {
background-color: lightblue;
}
h2 {
font: 2em sans-serif;
color: red;
}
a {
text-decoration: none
}
li {
list-style: none;
}
div#header, div#footer {
position: relative;
background-color: white;
margin: 20px 20px 0px 20px;
}
div#header a {
font: .75em sans-serif;
color: orange;
position: absolute;
margin-right: 0px;
right: 2px;
top: 0;
}
div#mainnav {
text-align: center;
margin: 0 20px 0 20px;
}
div#mainnav a {
position: relative;
float: left;
margin: 0px;
background-color: blue;
color: white;
padding: 0 20px;
}
div#mainnav a:hover {
background-color: white;
color: black;
}
div#container {
position: relative;
margin: 0 20px 0 20px;
}
div#articles,
div#products {
position: absolute;
width: 150px;
background-color: white;
top: 0;
bottom: 0;
}
div#articles {
left: 0;
}
div#products {
right: 0;
}
div#content {
margin: 0 150px 0 150px;
background-color: lightcyan;
}
div#footer {
text-align: center;
}
</style>
<body>
<div id='header'>
<h2>Logo</h2>
<a href=''>Contact Us</a>
</div>
<div id='mainnav'>
[list]
<li><a href=''>Home</a></li>
<li><a href=''>News</a></li>
<li><a href=''>People</a></li>
<li><a href=''>Places</a></li>
<li><a href=''>Jobs</a></li>
</ul>
</div>
<div id='container'>
<div id='articles'>
[list]
<li><a href=''>Article 1</a></li>
<li><a href=''>Article 2</a></li>
<li><a href=''>Article 3</a></li>
<li><a href=''>Article 4</a></li>
</ul>
</div>
<div id='content'>
<h1>Beach Balls</h1>
<p>Some interesting banter about beach balls. Some interesting banter about beach balls. Some interesting banter about beach balls. Some interesting banter about beach balls. Some interesting banter about beach balls. Some interesting banter about beach balls. Some interesting banter about beach balls. Some interesting banter about beach balls. Some interesting banter about beach balls. Some interesting banter about beach balls. Some interesting banter about beach balls. </p>
</div>
<div id='products'>
[list]
<li><a href=''>Product 1</a></li>
<li><a href=''>Product 1</a></li>
<li><a href=''>Product 1</a></li>
<li><a href=''>Product 1</a></li>
</ul>
</div>
</div>
<div id='footer'>
<a href=''>Product 1</a>
<a href=''>Product 1</a>
<a href=''>Product 1</a>
<a href=''>Product 1</a>
<a href=''>Product 1</a>
<a href=''>Product 1</a>
<a href=''>Product 1</a>
<a href=''>Product 1</a>
</div>
</body>
</html>
|
|

December 4th, 2005, 03:25 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
|
|
Ah, that makes much more sense.
First some structural tips. The IE7 JavaScript and just javascript in general should go either between the <head> and </head> elements of a document or between the <body> and </body> elements. The IE7 JavaScript should always be between the <head> and </head> elements, I recommend it should also appear after all other stylesheets. Stylesheets must always appear between <head> and </head> elements. Browsers are usually tolerant of mistakes like these, but that's the correct way to do it.
Your document was in dire need of a few "Holly" hacks. The Holly hack refers to the application of a height: 1%; declaration to an element, which forces Explorer to recalculate dimensions. You can learn more about the Holly hack at http://www.positioniseverything.net
Following is your code fixed up for cross-browser greatness, I've commented the changes that I made.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 strict//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Logo</title>
<style type="text/css">
body {
background-color: lightblue;
}
h2 {
font: 2em sans-serif;
color: red;
margin: 0; /* remove default margin */
}
a {
text-decoration: none
}
li {
list-style: none;
}
div#header, div#footer {
position: relative;
background-color: white;
margin: 20px 20px 0px 20px;
}
div#header a {
font: .75em sans-serif;
color: orange;
position: absolute;
margin-right: 0px;
right: 2px;
top: 0;
}
div#mainnav {
text-align: center;
margin: 0 20px 0 20px;
}
div#mainnav a {
position: relative;
float: left;
margin: 0px;
background-color: blue;
color: white;
padding: 0 20px;
}
div#mainnav a:hover {
background-color: white;
color: black;
}
div#mainnav ul {
margin: 0; /* Remove default margin and padding */
padding: 0;
}
div#mainnav li {
float: left; /* place the <li> elements beside each other */
}
div#container {
clear: both; /* Don't let the container float up beside the floated li elements */
position: relative;
margin: 0 20px 0 20px;
min-height: 400px; /* make sure the document always has a minimum height for consistency */
}
div#articles,
div#products {
position: absolute;
width: 150px;
background-color: white;
top: 0;
bottom: 0;
}
div#articles {
left: 0;
}
div#products {
right: 0;
}
div#content {
margin: 0 150px 0 150px;
background-color: lightcyan;
min-height: 400px; /* This needs a minimum height too */
}
div#footer {
text-align: center;
}
</style>
<!--[if lt IE 7]>
<script src="/ie7/ie7-standard-p.js" type="text/javascript"></script>
<style type='text/css'>
div#header,
div#container {
height: 1%; /* Holly Hack needed here to correct Explorer's quirky rendering */
}
</style>
<![endif]-->
</head>
<body>
<div id='header'>
<h2>Logo</h2>
<a href=''>Contact Us</a>
</div>
<div id='mainnav'>
[list]
<li><a href=''>Home</a></li>
<li><a href=''>News</a></li>
<li><a href=''>People</a></li>
<li><a href=''>Places</a></li>
<li><a href=''>Jobs</a></li>
</ul>
</div>
<div id='container'>
<div id='articles'>
[list]
<li><a href=''>Article 1</a></li>
<li><a href=''>Article 2</a></li>
<li><a href=''>Article 3</a></li>
<li><a href=''>Article 4</a></li>
</ul>
</div>
<div id='content'>
<h1>Beach Balls</h1>
<p>Some interesting banter about beach balls. Some interesting banter about beach balls. Some interesting banter about beach balls. Some interesting banter about beach balls. Some interesting banter about beach balls. Some interesting banter about beach balls. Some interesting banter about beach balls. Some interesting banter about beach balls. Some interesting banter about beach balls. Some interesting banter about beach balls. Some interesting banter about beach balls. </p>
</div>
<div id='products'>
[list]
<li><a href=''>Product 1</a></li>
<li><a href=''>Product 1</a></li>
<li><a href=''>Product 1</a></li>
<li><a href=''>Product 1</a></li>
</ul>
</div>
</div>
<div id='footer'>
<a href=''>Product 1</a>
<a href=''>Product 1</a>
<a href=''>Product 1</a>
<a href=''>Product 1</a>
<a href=''>Product 1</a>
<a href=''>Product 1</a>
<a href=''>Product 1</a>
<a href=''>Product 1</a>
</div>
</body>
</html>
Hope that helps!
Regards,
Rich
--
[ http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design
|
|

December 4th, 2005, 05:08 PM
|
|
Authorized User
|
|
Join Date: Nov 2005
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Indeed that was very helpful. Thanks!!!
And don't worry, I'll be back with plenty more questions, but not until I study over these holy hacks.
Best regards,
Ben
|
|

December 9th, 2005, 08:04 PM
|
|
Authorized User
|
|
Join Date: Nov 2005
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Now that I understand what a âhackâ actually is, I certainly agree. Thereâs nothing like incorporating into a system an inevitable failure to fix a problem.
I have a few more questions though, pertaining to the following code.
1. Are IE hacks as long as you isolate them in the <!â[if lt IE 7]>, because it is a âdeadâ browser? Couldnât it just rote on a server for the next thousand years and still work properly as long as the 3005 browsers support the ancient html and CSS and all the time ignoring the hack because it is lt IE7?
2. Is there any way in CSS to have a centered fluid design?
3. Only on IE there is a gap between the mainnav div and the bax1 box2 and box3 divs. I have set everything I can think of to margin: 0; and IE7 doesnât make a difference. Is this a bug?
4. Does IE7 cause IE to use the standard box model?
5. When using IE7 on a web page am I correct in understanding that since IE7 is a JavaScript that if a person accessing that site with IE and has not enabled JavaScript that it will render with all the non-support for CSS?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 strict//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<style type="text/css">
html {
background: white url(mossy_tree_1.jpg) no-repeat fixed center center;
}
body {
padding: 0px;
margin: 40px 60px;
min-width: 500px;
max-width: 900px;
-moz-opacity: 0.7;
-khtml-opacity: 0.7;
filter:progid:DXImageTransform.Microsoft.Alpha(opa city=70);
opacity: 0.7;
}
a {
text-decoration: none;
color: white;
}
a:hover {
color: black;
}
h1 {
font: 3em monotype-corsiva;
margin: 0;
padding: 0;
}
ul {
list-style: none;
}
div#header {
margin: 0;
padding: 0 0 0 5px;
background-color: darkgreen;
color: goldenrod;
border-top: 1px solid white;
border-right: 1px solid white;
border-bottom: 3px solid white;
border-left: 3px solid white;
}
div#header a {
position: absolute;
color: white;
font: bold .6em sans-serif;
margin: 0;
padding: 0;
}
div#header h2#contact a {
top: 50px;
right: 70px;
}
div#header h2#hours a {
top: 70px;
right: 70px;
}
div#mainnav {
margin: 0;
padding: 0;
}
div#mainnav ul {
margin: 5px 0 0 0;
padding: 0;
}
div#mainnav li {
float: left;
border-top: 1px solid white;
border-right: 1px solid white;
border-bottom: 2px solid white;
border-left: 2px solid white;
}
div#mainnav li a {
font-weight: bold;
background-color: green;
padding: 0 10px;
}
div#mainnav li a:hover {
background-color: white;
}
div#container {
margin: 0;
padding: 0;
clear: both;
position: relative;
min-height: 150px;
width: 550px;
}
div#box1, div#box2, div#box3 {
position: absolute;
margin: 0;
padding: 0;
top: 0;
bottom: 0;
color: green;
background-color: yellow;
border-top: 1px solid white;
border-right: 1px solid white;
border-bottom: 3px solid white;
border-left: 3px solid white;
width: 150px;
min-height: 150px;
-moz-opacity: 0.9;
-khtml-opacity: 0.7;
filter:progid:DXImageTransform.Microsoft.Alpha(opa city=70);
}
div#box1 {
left: 0;
}
div#box2 {
left: 200px
}
div#box3 {
left: 400px;
}
div#content {
background-color: white;
margin: 10px 0;
padding: 5px;
}
</style>
<!--[if lt IE 7]>
<style type='text/css'>
div#box1, div#box2, div#box3 {
height: 150px;
}
div#container {
height: 150px;
}
</style>
<![endif]-->
</head>
<body>
<div id='header'>
<h1>Logo</h1>
<h2 id='contact'><a href=''>Contact Us</a></h2>
<h2 id='hours'><a href=''>Open Hours</a></h2>
</div>
<div id='mainnav'>
[list]
<li><a href=''>Home</a></li>
<li><a href=''>Staff</a></li>
<li><a href=''>Dr. Malpretis</a></li>
<li><a href=''>Vaccines</a></li>
<li><a href=''>Ninnies</a></li>
<li><a href=''>Home</a></li>
<li><a href=''>Staff</a></li>
<li><a href=''>Dr. Malpretis</a></li>
</ul>
</div>
<div id='container'>
<div id='box1'>
<h3>Puppy Starter Kits</h3>
<h3>Kitten Starter Kits</h3>
</div>
<div id='box2'>
<h3>General Care</h3>
</div>
<div id='box3'>
<h3>Old Dogs</h3>
</div>
</div>
<div id='content'>
<h1>Title</h1>
<p>This is some text about veterinary services and care. This is some text about veterinary services and care.This is some text about veterinary services and care.This is some text about veterinary services and care.This is some text about veterinary services and care.This is some text about veterinary services and care.This is some text about veterinary services and care.This is some text about veterinary services and care.This is some text about veterinary services and care.This is some text about veterinary services and care.This is some text about veterinary services and care.This is some text about veterinary services and care.This is some text about veterinary services and care.This is some text about veterinary services and care.This is some text about veterinary services and care.This is some text about veterinary services and care.This is some text about veterinary services and care.This is some text about veterinary services and care.</p>
</div>
</body>
</html>
|
|

December 12th, 2005, 10:57 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
|
|
> 1. Are IE hacks as long as you isolate them in the <!â[if lt IE 7]>, because it is a âdeadâ browser? Couldnât it just rote on a server for the next thousand years and still work properly as long as the 3005 browsers support the ancient html and CSS and all the time ignoring the hack because it is lt IE7?
Any hack that is dead or isolated is fine in my opinion. :) That's why I'm a big proponent of conditional comments, they target the browser that they are needed for. When the real IE7 comes out we'll have to rethink design and hacks anyway. I hope by the time 3005 gets here the technology will have finally evolved beyond the need for hacks.
> 2. Is there any way in CSS to have a centered fluid design?
I need more information to answer this.
> 3. Only on IE there is a gap between the mainnav div and the bax1 box2 and box3 divs. I have set everything I can think of to margin: 0; and IE7 doesnât make a difference. Is this a bug?
It would help me if you would post a URL instead of source code, it makes it much easier to answer your questions. ;) Ever use the web developer toolbar for Firefox? It let's me tweak CSS live without actually pulling it up in a text editor.
> 4. Does IE7 cause IE to use the standard box model?
No, providing certain Document Type Declarations causes IE6 to use the standards box model. IE7 does do some box model tinkering with IE5 and 5.5 though.
http://msdn.microsoft.com/workshop/a...ts/doctype.asp
> 5. When using IE7 on a web page am I correct in understanding that since IE7 is a JavaScript that if a person accessing that site with IE and has not enabled JavaScript that it will render with all the non-support for CSS?
Yes, switching off JavaScript turns off IE7. You can alert people to this by providing a message between <noscript> tags.
HTH!
Regards,
Rich
--
[ http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design
|
|

December 12th, 2005, 04:32 PM
|
|
Authorized User
|
|
Join Date: Nov 2005
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
What I mean by center fluid design is, is there a way to have the site calculate from the center out evenly, rather from the upper left corner right and down, as the default seems to be. Similar to center justified text, but site rendering.
In the future I will post a url. I did not have one until now, except for a site on register.com which I have been planning on redoing. I registered for a free 50meg.com site, it is free but there are a bunch of banners everywhere. I am planning on getting a good package from hostexelence.com soon. I downloaded that firefox web tool bar. It looks very useful although I am not sure exactly what for except for the validating tools. If you can use it to tweak thatâs hard core, feel free to tweak all you want.
One thing I did that didnât so much answered my question about the gap left by IE but fixed it and some other stuff was putting a * {margin: 0; padding: 0;} at the to of my CSS. Then I could remove all the margin: 0 and padding: 0âs and same space then add the margins and padding I wanted.
I have published a page to http://efficientpresence.50megs.com/Erroneous.htm if you would like to take a look. Youâll have to ignore the banners.
|
|
 |