Be a Supporter!

Css Help

  • 639 Views
  • 10 Replies
New Topic Respond to this Topic
15DAVE15
15DAVE15
  • Member since: Mar. 19, 2008
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Css Help 2009-06-17 08:05:53 Reply

K, now, l am new to CSS and l am making a page just to test some of my skills with HTML and CSS, l would like a menu on the left hand side of the page, with Home, etc. Is there any CSS coding l could use for this, or don't they making CSS for this situation???

BillysProgrammer
BillysProgrammer
  • Member since: Sep. 17, 2008
  • Offline.
Forum Stats
Member
Level 16
Gamer
Response to Css Help 2009-06-17 09:28:12 Reply

With CSS, you can make almos anything :P

Basically, if you want the navigation bar on the left to be beside the content (on the right), you would set a width for both, float the nav bar to the left, and content to the right.

Example:

/* CSS Structure Code */
#container { margin: 0px auto; width: 1000px; } /* margin: 0px auto; to align the div to the center of the page */
#nav_sidebar { float: left; width: 250px; }
#nav_sidebar ul { list-style: none; }
#content_main { float: right; width: 750px; }

/* (X)HTML */
<div id="container">
  <div id="nav_sidebar">
    <ul>
      <li><a href="">Home</a></li>
    </ul>
  </div>
  <div id="content">
    <h2>This is a test</h2>
    <p>Hey, it works!</p>
  </div>
</div>
smulse
smulse
  • Member since: Mar. 24, 2005
  • Offline.
Forum Stats
Member
Level 31
Blank Slate
Response to Css Help 2009-06-17 10:32:57 Reply

If you're going to tell someone about floats, please tell them about clear too.

When you float elements, the container those elements are in will lose height.

Here's an example:

#container {  }
#foo { float: left;  }
#bar { float: right;  }

<div id="container">
  <div id="foo"></div>
  <div id="bar"></div>
</div>

In the above code, the #container won't take into account the heights of #foo or #bar, which is a problem if you wanted to sit any content below these, or a footer, etc.

So, to stop this element losing height we do:

#container {  }
#foo { float: left;  }
#bar { float: right;  }
.clear { clear: both; }

<div id="container">
  <div id="foo"></div>
  <div id="bar"></div>
<div class="clear"></div>
</div>

There are many ways to clear floats, this is an inefficient way of doing so, but it's also the simplest and easiest to understand without going into any CSS hacks or getting too complicated for a beginner.


BBS Signature
15DAVE15
15DAVE15
  • Member since: Mar. 19, 2008
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to Css Help 2009-06-18 04:02:38 Reply

l was trying to change all of that into HTML and thought that maybe l had jumped a bit far into this stuff. So l am going to go back to the start where l should only need HTML, say l am wanting to make a sidebar with buttons to different pages of the website on it, how would l do this, build it as one whole thing or split it up, (sidebar, button1, button2, etc)... ???

psicodemon
psicodemon
  • Member since: Aug. 1, 2004
  • Offline.
Forum Stats
Member
Level 28
Blank Slate
Response to Css Help 2009-06-18 07:06:44 Reply

Well you can do it with tables or frames to................................... but if you done that and read + understand how to do it in css your going to knock yourself for ever doing it in frames or tables.

but frames is pretty easy to create a side bar, just google for HTML frames, not sure if you understand how it works with 2 websites ( you make 2 html pages one with the navigation and one with the text )

Tables could be done to by creating like one big table that holds 3 horizontal rows, and then add another table to the left one with your menu (so table in a table ) ... It all gets really messy but there are tutorials for it, maybe give it a try and if you get positioning with html you can start css, since css does it faster / better.

good luck

BillysProgrammer
BillysProgrammer
  • Member since: Sep. 17, 2008
  • Offline.
Forum Stats
Member
Level 16
Gamer
Response to Css Help 2009-06-18 08:38:00 Reply

At 6/17/09 10:32 AM, smulse wrote: post

I guess your right, but the one thing that a lot of other people do is add extra semantic markup. You don't really need to add a extra div to clear when you can place the footer outside the container and have the clearing on that; Although, sometimes you do need it and it is easier to do.

smulse
smulse
  • Member since: Mar. 24, 2005
  • Offline.
Forum Stats
Member
Level 31
Blank Slate
Response to Css Help 2009-06-18 10:10:17 Reply

At 6/18/09 04:02 AM, 15DAVE15 wrote: l was trying to change all of that into HTML and thought that maybe l had jumped a bit far into this stuff. So l am going to go back to the start where l should only need HTML

HTML is used to describe what is on the page, and CSS is used to style and present it. It's not you pick one or the other, you use them both, together, to make a website.

At 6/18/09 08:38 AM, BillysProgrammer wrote: I guess your right, but the one thing that a lot of other people do is add extra semantic markup. You don't really need to add a extra div to clear when you can place the footer outside the container and have the clearing on that; Although, sometimes you do need it and it is easier to do.

Yeah, like I said in my post its an inefficient way of doing it, but it's also the easiest. A lot of times you can be floating things inside, it's not always the main columns of a page you're floating so there's not always a footer to use to clear them.

Either way it's still an important thing to mention when you're telling people about floats, even if you say that the method of clearing you're using isn't the most efficient.


BBS Signature
scratchisthebest
scratchisthebest
  • Member since: May. 26, 2009
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to Css Help 2009-06-26 17:40:13 Reply

Try:
#foo { float: left; clear: both; }
#bar { float: right; clear:both; }
I'm not very good at css, so just an idea.


Seach google for bubbleswingers!
Why?
'Cause it's pointless!

urbn
urbn
  • Member since: Jun. 10, 2007
  • Offline.
Forum Stats
Member
Level 18
Programmer
Response to Css Help 2009-06-26 21:07:29 Reply

At 6/26/09 05:40 PM, scratchisthebest wrote: I'm not very good at css, so just an idea.

Why are you posting then? Especially when the answer has already been given...


BBS Signature
Wonderful
Wonderful
  • Member since: Jul. 27, 2008
  • Offline.
Forum Stats
Member
Level 13
Blank Slate
Response to Css Help 2009-06-27 10:08:32 Reply

At 6/26/09 05:40 PM, scratchisthebest wrote: Try:
#foo { float: left; clear: both; }
#bar { float: right; clear:both; }
I'm not very good at css, so just an idea.

This is exactly how you don't do it. Clearing #foo and #bar will make it so nothing can float next to it.


Posted from Linux. Distro may vary.