/    Sign up×
Community /Pin to ProfileBookmark

Help the CSS beginner with a basic design

Lo there,

I saw some great designs made with CSS instead of frames. I’d like to throw myself into CSS too. I’ve uploaded a picture of how I’d like my first full CSS design should be, can anyone help me by posting a clue or a tutorial about how to do something like this?

To be completely clear: I have no idea how to make them boxes (pbb div’s or something) in position and with the right dimentions.

[upl-file uuid=5fc0270f-7275-4c6e-92b9-bf5fa0396e18 size=63kB]teh_frames.jpg[/upl-file]

to post a comment
CSS

30 Comments(s)

Copy linkTweet thisAlerts:
@ShrineDesignsDec 19.2005 — here is an example<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css">
<!--
html {
overflow: hidden;
}
html,
body {
height: 100%;
}
body {
margin: 0%;
padding: 0%;
}
#header {
clear: both;
width: 100%;
height: 20%;
}
#menu {
float: left;
width: 20%;
height: 80%;
}
#content {
float: right;
width: 80%;
height: 70%;
}
#footer {
float: right;
width: 80%;
height: 10%;
}
-->
</style>
</head>
<body>
<div id="header">header</div>
<div id="menu">menu</div>
<div id="content">content</div>
<div id="footer">footer</div>
</body>
</html>
Copy linkTweet thisAlerts:
@PimmauthorDec 19.2005 — That's what I needed, and it's works with the W3 standards too.

Only one thing and then I'll go and try this on my own:

The header's height, menu's width and the footer's height should have a strickt value (instead of a %-value), let's say 50, 80 and 20. Is this possible? Because just changing the %-value's to normal ones doesn't seem to work.
Copy linkTweet thisAlerts:
@KDLADec 19.2005 — Here's a template I devised for a library with a similar layout: http://kdla.ky.gov/_test/librarytemplates/untitled-basic-css.htm

Feel free to use it.

KDLA
Copy linkTweet thisAlerts:
@PimmauthorDec 19.2005 — Thanks, I'll check it out. One tiny thing about your website (not to be enoying), you're using XHTML, so this line:[code=html]<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">[/code]should be like this[code=html]<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />[/code](see the last characters).

Anyways, thanks for the link!

[b]Edit[/b]: No sorry, I still can't get it to work... can somebody push me in the right direction?
Copy linkTweet thisAlerts:
@KDLADec 19.2005 — Thanks -

Dreamweaver always screws up that stuff. Sometimes I forget to check. :rolleyes:

KDLA
Copy linkTweet thisAlerts:
@PimmauthorDec 20.2005 — Glad I could help.

Now back on topic: Because I'm not really good with CSS I tried to use the source of the link posted above, but I totally screwed up. Can somebody help me with the CSS one more time?
Copy linkTweet thisAlerts:
@KDLADec 20.2005 — You'll need to be more specific about what type of help you require. Maybe provide a link to your document (that you screwed up) and what types of tweaks need to be done.

KDLA
Copy linkTweet thisAlerts:
@PimmauthorDec 20.2005 — K look, I tried to make the dimentions and stuff how I want it to be, and [url=http://milkheaven.com/testcss.html]this is the result (link)[/url]:[code=html]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>CSS design, but screwed up :)</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css">
<!--
html {
overflow: hidden;
}
html,
body {
height: 100%;
}
body {
margin: 0%;
padding: 0%;
}
#header {
background-color:#6699FF;
clear: both;
width: 100%;
height: 50px;
}
#menu {
background-color:#33FF00;
float: left;
width: 120px;
height: 80%;
}
#content {
background-color:#9966FF;
float: right;
width: 80%;
height: 70%;
}
#footer {
background-color:#FFCCCC;
float: right;
width: 80%;
height: auto;
}
-->
</style>
</head>
<body>
<div id="header">header</div>
<div id="menu">menu</div>
<div id="content">content</div>
<div id="footer">footer</div>
</body>
</html>[/code]
The menu should take 100% of the screen for height... minus the 50px of the header. Both the content and the footer should be 100% width minus the 120px of the menu and the content should stretch out so far vertically that the footer hits the ground, and the entire page will be filled.

The header and the menu will be filled with 100% dimentions Flash objects, the content will be filled with a 100% dimentions iframe and the footer with just plain text.
Copy linkTweet thisAlerts:
@KDLADec 20.2005 — OK. That helps.

There seems to be some confusion as to how to place items and determining their dimensions.

"Height" in percentages doesn't exist in CSS. Most browsers will determine the height of an element by the amount of content displayed [I]within[/I] that particular element. The element will not (and can not) be stretched to accommodate blank space on the screen. You can use pixel values, but that doesn't guarantee that the layout will be perfectly displayed, due to the various screen resolution settings.

One way to have a floated columns, such as the menu, stretch to 100% of the screen is to use a background image that is sectioned off into columns (as with color blocks). You would place this image setting in a container <div> that surrounds your content.

The float property only needs to be applied to your menu, not to the rest of the elements in your page.

The coding below should bring you closer to your desired result.
<i>
</i>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;CSS design, but screwed up :)&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;meta http-equiv="Content-Style-Type" content="text/css"&gt;
&lt;style type="text/css"&gt;
body {
margin: 0%;
padding: 0%;
}
#header {
background-color:#6699FF;
width: 100%;
height: 50px;
}
#menu {
background-color:#33FF00;
float: left;
width: 120px;
}
#content {
background-color:#9966FF;
width: 100%;
margin-left: 120px;
}
#footer {
background-color:#FFCCCC;
width: 100%;
margin-left: 120px;
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id="header"&gt;header&lt;/div&gt;
&lt;div id="menu"&gt;menu&lt;/div&gt;
&lt;div id="content"&gt;content&lt;/div&gt;
&lt;div id="footer"&gt;footer&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;

KDLA
Copy linkTweet thisAlerts:
@WebJoelDec 20.2005 — You seem to have a few replies so I won't add anything right now, -but if you ever need to get a quick, 100% FREE to use anytime, compliant cross-browser -or just something to 'get you started'- *css template, check you must check out this URL:

http://www.strangebanana.com (and follow direction for use)

This site uses a 'random page generator' to create web page templates, and admittedly, 9 out of 10 of them will look like crap, every so often you will get a really sweet-looking version from which you can save the code for you use.

From there, you can revise, tweak, add, delete, etc. to your heart's content!

-Just be SURE that if/when you get a good-looking template, that you SAVE it then and there, because if you call-up another random site, then decide to go 'back', the site that you liked will no longer be there. You will get another completely different page, as the 'generator' will stir the pot once again...

I really like visiting this (strangebanana) site. ?

Enjoy and have fun!

-Joel
Copy linkTweet thisAlerts:
@bokehDec 20.2005 — [code=html]<style type="text/css">
html {
overflow: hidden;
}
html, body {
height: 100%;
}
body {
margin: 0%;
padding: 0%;
}
#header {
background-color:#6699FF;
width: 100%;
height: 50px;
}
#menu {
background-color:#33FF00;
position:absolute;
left:0px;
top:50px;
width: 120px;
height: 100%;
padding-bottom: 50px;
z-index:1;
}
#content {
background-color:#9966FF;
position:absolute;
left:0;
top:50px;
width: 100%;
height: 100%;
padding-bottom: 50px;
padding-left:120px;
}
#footer {
background-color:#FFCCCC;
position:absolute;
left:0;
bottom:0;
height:50px;
width: 100%;
z-index:2;
}
</style>[/code]
Copy linkTweet thisAlerts:
@PimmauthorDec 21.2005 — Thanks everyone. I [url=http://milkheaven.com/testcss.html]updated the page[/url]. As you can see, my problem is now that the content div stretches out too far, which makes the iframe in it also stretch out too far. And another thing, when I use my middle mouse button (or wheel, whatever) I'll be able to get under and to the right of the website, which is kinda not good. Can this be fixed or was KDLA right, and should I totally do it in another way?
Copy linkTweet thisAlerts:
@bokehDec 21.2005 — [B]<iframe>[/B]

You have used the element named above in your document, but the document type you are using does not define an element of that name.
Copy linkTweet thisAlerts:
@PimmauthorDec 21.2005 — I changed the doctype to XHTML 1.0 Transitional to make it Valid by the W3... same thing happens though.
Copy linkTweet thisAlerts:
@bokehDec 21.2005 — Personally I'd use strict and no iframe!
Copy linkTweet thisAlerts:
@PimmauthorDec 21.2005 — OK, I'll loose the iframe. Still, you guys must have something that disables the "clicking middle mouse button and scrolling to out of the page" thingy?
Copy linkTweet thisAlerts:
@ray326Dec 21.2005 — Hmm. Looks ok to me in Fx and IE6.
Copy linkTweet thisAlerts:
@bokehDec 21.2005 — To me too!
Copy linkTweet thisAlerts:
@PimmauthorDec 21.2005 — Look, I threw in some lorem ipsum to explain what my problem is ([url=http://milkheaven.com/testcss.html]link[/url]).

As you can see, I tried to fix it by using a "overflow:scroll;" rule, but it still doesn't work well. It scrolls, but not all the text is displayed.
Copy linkTweet thisAlerts:
@KDLADec 21.2005 — This is an evil tag:

overflow: hidden;

I don't recommend your using it, at least until you learn more about screen resolutions. But, that's a totally different tangent....

By the way, you [I]still[/I] need to take out those height: 100% settings from all your divs. They don't work.

As to this
<i>
</i>#content {
background-color:#9966FF;
position:absolute;
left:0;
top:100px;
width:100%;
height:100%;
padding-bottom:50px;
padding-left:180px;
overflow:scroll;
}


You need to define a REAL height, in pixels:
<i>
</i>#content {
background-color:#9966FF;
position:absolute;
top:100px;
width:100%;
height:600px;
max-height: 600px;
overflow:scroll;
}


Add the padding settings to another <div> placed inside this one, in which you'll actually place your text.

KDLA
Copy linkTweet thisAlerts:
@PimmauthorDec 21.2005 — So the thing you're telling me is: you cannot stretch your div's to full fit? I see your solution, but I really want everything to fit nicely.
Copy linkTweet thisAlerts:
@KDLADec 21.2005 — Height, in percentages, doesn't exist. You can stretch your divs by guessing the amount in pixels, but that won't be accurate for every user, since there are several types of screen resolutions out there. Like, if you had it height:600px to fit 800x600. It won't fit perfectly for those with 1024x768; there will be 168px of blank space at the bottom. Conversley, if you do height: 768 and the user has 800x600, they'll not see the bottom portion. (Especially if you use that evil overflow: hidden style setting.)

Just keep plugging away. I suggest you go to your public library and borrow a copy of Cascading Style Sheets: The Definitive Guide by Eric Meyer. (Also available through Amazon.com) It has lots of information in it that will help you.

KDLA
Copy linkTweet thisAlerts:
@ray326Dec 22.2005 — Delete the position:absolute and the width:100% from the #content.
Copy linkTweet thisAlerts:
@bokehDec 22.2005 — Height, in percentages, doesn't exist.[/QUOTE]Yes it does! Height can take one of four values: [I]auto[/I] | [I]inherit [/I]| [I]percentage [/I]| [I]length[/I].
Copy linkTweet thisAlerts:
@KDLADec 22.2005 — bokeh -

Is that true in ALL browsers? I've not been fortunate enough to come up with something [body{height: 100%;}] that works in both IE and FF.

Also, doesn't a height have to be defined in a container div, instead of in the body?

Example -

<div style="height: 500px;">

<div style="height: 100%;>

<p>content.... yadda, yadda, yadda....</p>

</div>

</div>

I'm not trying to be argumentative, only trying to learn something.
Copy linkTweet thisAlerts:
@PimmauthorDec 22.2005 — OK, thanks for all your help. I found out that CSS is just harder than I thought. Because of your replies I've learned some things about CSS and I'll make it from scratch. I think I know how to now.

Thanks everyone!
Copy linkTweet thisAlerts:
@bokehDec 22.2005 — bokeh -

Is that true in ALL browsers? I've not been fortunate enough to come up with something [body{height: 100%;}] that works in both IE and FF.[/QUOTE]
height is CSS1 so it should work in all browsers. Unfortunately it doesn't though. IE handles the [I]height[/I] property as all other modern browsers handle [I]min-height[/I]. Also IE doesn't even recognise [I]min-height[/I]. (How will IE7 handle this?)
Copy linkTweet thisAlerts:
@KDLADec 22.2005 — Didn't think that it worked. When you first wrote that, I had one of those time/dream sequences where every frustrating coding moment shuttled through my memory.

IE really stinks. Unfortunately, most of our (KDLA's) users have it, since most public libraries' computers are provided by the Gates Foundation.

I've heard that IE 7 is supposed to be better about CSS -- guess we'll have to wait and see.

Thanks for the information & Feliz Navidad! -

KDLA
Copy linkTweet thisAlerts:
@ray326Dec 22.2005 — I think the problem is there has to be an enclosing height that the percentage height can be calculated against. At any rate I believe what I told you to do works for your particular problem.
Copy linkTweet thisAlerts:
@sourjonDec 25.2005 — Merry Christmas from Louisville, Kentucky! I have experimenting with CSS for the last four weeks and found the Sam's Teach Yourself CSS in 24 Hours book very helpful for a beginner like myself. There is a website associated with is as well: www.cssin24hours.com

Also I have downloaded a slick toolbar extension for Firefox called WebDeveloper that will greatly help with page development. It will show you the stylesheet for any page. Looking at these helped me tremendously. Seeing something work well and looking at the code is a great way to learn. At least it was for me. It can be had here:http://chrispederick.com/work/webdeveloper/

Hope this helps.
×

Success!

Help @Pimm spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...