Reply to topic  [ 12 posts ] 
XHTML/CSS 
Author Message
Doesn't have much of a life
User avatar

Joined: Thu Apr 23, 2009 7:16 pm
Posts: 704
Location: Leeds, UK
Reply with quote
I know this isn't exactly "meeting place" material, but I hope the attachment will help.

Basically i'm doing some website coding for a module where i've got to design a website. The lectures weren't exactly helpful, so i've been teaching myself using t'internet and it's been slow going.

One thing I can't work out how to do is to create a box which will contain everything and that is centered (much like THIS page.

Anyone good at website programming?

*looks hopeful and offers pie*

Image


Mon May 04, 2009 7:32 pm
Profile WWW
Spends far too much time on here
User avatar

Joined: Thu Apr 23, 2009 9:40 pm
Posts: 4876
Location: Newcastle
Reply with quote
By 'white box' that is centred do you mean the white and all that is contained within it?

If so it looks like a relative CSS style setting with say 5% left start and 95% right finish, then you whack all the stuff you want inside it. set a 1% border top & bottom say.

And Bob is your proverbial man from U.N.C.L.E. .... or something like that ;)

Did you not look at the source for the page? there would be a link somewhere in the source to the CSS if it is referenced and not embedded.

the CSS file is : HERE

The actual source of the site will help you find out what does what

_________________
Twitter
Charlie Brooker:
Macs are glorified Fisher-Price activity centres for adults; computers for scaredy cats too nervous to learn how proper computers work; computers for people who earnestly believe in feng shui.


Mon May 04, 2009 7:42 pm
Profile
What's a life?
User avatar

Joined: Thu Apr 23, 2009 8:25 pm
Posts: 10691
Location: Bramsche
Reply with quote
You just need to put the content into its own <div> tag, giving it either an id or a class (class is generally preferred, but if it is unique on the page, id is okay as well.

Then set up the CSS for the div's class or id.

E.g. in you xhtml file:
Code:
<div class="main_content">blah blah blah</div>



In your css file:

Code:
.main_content {
    border : solid 1px black;
    width : 50%;
    left: 25%;
}

Just fill in the code you need to apply the formatting.

A good place to start is w3schools.com

_________________
"Do you know what this is? Hmm? No, I can see you do not. You have that vacant look in your eyes, which says hold my head to your ear, you will hear the sea!" - Londo Molari

Executive Producer No Agenda Show 246


Mon May 04, 2009 7:44 pm
Profile ICQ
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 9:40 pm
Posts: 5288
Location: ln -s /London ~
Reply with quote
big_D wrote:
class is generally preferred, but if it is unique on the page, id is okay as well
Why so, out of curiosity? I always use ID if it is unique, to force it to be unique and stop it being used where it's not intended to be.

Edd

_________________
timark_uk wrote:
Gay sex is better than no sex

timark_uk wrote:
Edward Armitage is Awesome. Yes, that's right. Awesome with a A.


Mon May 04, 2009 9:18 pm
Profile
Doesn't have much of a life
User avatar

Joined: Thu Apr 23, 2009 7:16 pm
Posts: 704
Location: Leeds, UK
Reply with quote
Okay i've put it in it's own class, and did "left: 20%;" but it is still aligning left, very strange. How do I make it centre? =/

But thanks for the boxage help =) I sorta figured it out just as I posted but didn't consider doing it as a percentage (which I think I might do it as now).


Mon May 04, 2009 9:35 pm
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 6:36 pm
Posts: 5150
Location: /dev/tty0
Reply with quote
EddArmitage wrote:
big_D wrote:
class is generally preferred, but if it is unique on the page, id is okay as well
Why so, out of curiosity? I always use ID if it is unique, to force it to be unique and stop it being used where it's not intended to be.

Edd


We were always told one would use an ID for a specific thing, it could be specific to a single page, or a site-wide specific thing like the main body div. One would use a class for less specialist circumstances, like a class for making any picture float left or right.


Mon May 04, 2009 9:54 pm
Profile WWW
Spends far too much time on here
User avatar

Joined: Thu Apr 23, 2009 11:36 pm
Posts: 3527
Location: Portsmouth
Reply with quote
forquare1 wrote:
EddArmitage wrote:
big_D wrote:
class is generally preferred, but if it is unique on the page, id is okay as well
Why so, out of curiosity? I always use ID if it is unique, to force it to be unique and stop it being used where it's not intended to be.

Edd


We were always told one would use an ID for a specific thing, it could be specific to a single page, or a site-wide specific thing like the main body div. One would use a class for less specialist circumstances, like a class for making any picture float left or right.


Yeah, exactly. Using a class in this instance would be pretty pointless.

You would also need the "line position:relative;" in the css for that <div>

_________________
Image


Mon May 04, 2009 10:35 pm
Profile
What's a life?
User avatar

Joined: Thu Apr 23, 2009 8:25 pm
Posts: 10691
Location: Bramsche
Reply with quote
Yep. If the item can be used more than once, then it should be a class. If it is unique, use Id.

Also, if you have several input fields on a form, for example, each would have an Id, but you would give them all the same class, so that you only need to define the style once and they all look the same...

Yes, position:relative is also needed. I didn't want to include all of the CSS he would need, just get him started, so that he actually learnt how it works and how to research it on his own. ;)

As a hint, Angelic, you will probably need to define the width and height of the body and / or html styles:

Code:
html {
    width : 100%;
}

body {
    width : 100%;
}


For example.

_________________
"Do you know what this is? Hmm? No, I can see you do not. You have that vacant look in your eyes, which says hold my head to your ear, you will hear the sea!" - Londo Molari

Executive Producer No Agenda Show 246


Tue May 05, 2009 4:43 am
Profile ICQ
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 9:40 pm
Posts: 5288
Location: ln -s /London ~
Reply with quote
Nick wrote:
forquare1 wrote:
We were always told one would use an ID for a specific thing, it could be specific to a single page, or a site-wide specific thing like the main body div. One would use a class for less specialist circumstances, like a class for making any picture float left or right.


Yeah, exactly. Using a class in this instance would be pretty pointless.

You would also need the "line position:relative;" in the css for that <div>
Well yes, I agree entirely, but I still don't see why class is "preferred". Surely ID is preferred, where it is suitable, but in most cases you have to use class or duplicate lots and lots of CSS, which is obviously *VERY* bad.

Edd

_________________
timark_uk wrote:
Gay sex is better than no sex

timark_uk wrote:
Edward Armitage is Awesome. Yes, that's right. Awesome with a A.


Tue May 05, 2009 11:10 am
Profile
Spends far too much time on here
User avatar

Joined: Thu Apr 23, 2009 11:36 pm
Posts: 3527
Location: Portsmouth
Reply with quote
big_D wrote:
Also, if you have several input fields on a form, for example, each would have an Id, but you would give them all the same class, so that you only need to define the style once and they all look the same...


It's interesting how people do things differently. I would always prefer to refer to the input element itslef in the css. If there was more than one form, I'd give each form an ID and do it that way.

I tend to use as few classes as possible. I think it's because I like to keep the HTML as clean as possible and also because classes are mis-used so often - it's a pet hate of mine.

_________________
Image


Tue May 05, 2009 11:21 am
Profile
Spends far too much time on here
User avatar

Joined: Thu Apr 23, 2009 11:36 pm
Posts: 3527
Location: Portsmouth
Reply with quote
EddArmitage wrote:
Nick wrote:
forquare1 wrote:
We were always told one would use an ID for a specific thing, it could be specific to a single page, or a site-wide specific thing like the main body div. One would use a class for less specialist circumstances, like a class for making any picture float left or right.


Yeah, exactly. Using a class in this instance would be pretty pointless.

You would also need the "line position:relative;" in the css for that <div>
Well yes, I agree entirely, but I still don't see why class is "preferred". Surely ID is preferred, where it is suitable, but in most cases you have to use class or duplicate lots and lots of CSS, which is obviously *VERY* bad.

Edd


I agree. As I hinted in my previous post, for me a class is NEVER preferred. Of course, they are sometimes the best option, but very rarely.

_________________
Image


Tue May 05, 2009 11:25 am
Profile
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 9:40 pm
Posts: 5288
Location: ln -s /London ~
Reply with quote
Nick wrote:
I agree. As I hinted in my previous post, for me a class is NEVER preferred. Of course, they are sometimes the best option, but very rarely.
Yes, just read your post and we're on the self-same wavelength.

Edd

_________________
timark_uk wrote:
Gay sex is better than no sex

timark_uk wrote:
Edward Armitage is Awesome. Yes, that's right. Awesome with a A.


Tue May 05, 2009 4:44 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 12 posts ] 

Who is online

Users browsing this forum: No registered users and 74 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.