View Full Version : CSS/Div Help
SmileUK
27-11-2007, 11:08 PM
How do I get a div to appear in a certain place on the page.
Such as
.main {
width: 500px;
float: 200px;
}
<div class="main">Main Content</div>
This doesn't work by the way.
So I want it to appear 200px in from the side, but I don't know how to do this, any help please.
Colin-Roberts
27-11-2007, 11:20 PM
margin-left:200px;
SmileUK
27-11-2007, 11:27 PM
Doesn't really matter now because it is tottally different in IE and in FF.
Cheers for the help though.
RedCrisps
28-11-2007, 12:59 PM
i would use the space bar :]
RYANNNNN
28-11-2007, 01:01 PM
You can't use the space bar because only 1 space would be counted...
It's happened because you are using float: 200px;
You can only use float: left or right;
RedCrisps
28-11-2007, 01:02 PM
so yah :]
Decode
28-11-2007, 03:49 PM
use;
margin-left: 200px;
or
body {padding-left: 200px;}
craigg.
28-11-2007, 05:09 PM
How do I get a div to appear in a certain place on the page.
Such as
.main {
width: 500px;
float: 200px;
}
<div class="main">Main Content</div>
This doesn't work by the way.
So I want it to appear 200px in from the side, but I don't know how to do this, any help please.
Have a try with:
// CSS Code
.main {width: 500px; float: left; margin-left: 200px;}
<!-- HTML Code -->
<div class="main"> Floating left with 200px margin! Possibly add padding?</div>
Great to see someone expanding their knowledge.
RYANNNNN
28-11-2007, 05:25 PM
Just a tip to the OP, main is only usually used once, so use an id, #main { } and <div id="main"> etc.
craigg.
28-11-2007, 05:34 PM
Classes can be applied more than once, ID's cant. (Just to clarify what Ryan had said)
Just a tip to the OP, main is only usually used once, so use an id, #main { } and <div id="main"> etc.
But it would work if he just used class wouldn't it?
So why use id's?
(it may sound like a stupid question, but I tend to use classes, I never knew there was anything wrong with it)
Invent
28-11-2007, 05:56 PM
But it would work if he just used class wouldn't it?
So why use id's?
(it may sound like a stupid question, but I tend to use classes, I never knew there was anything wrong with it)
As it's just better practise to use an ID if the class is only going to be used once.
As it's just better practise to use an ID if the class is only going to be used once.
Ahh thank you +rep :) And now I'm going to stop hijacking this thread.
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.