Be Excellent To Each Other

And, you know, party on. Dude.

All times are UTC [ DST ]




Reply to topic  [ 16 posts ] 
Author Message
 Post subject: CSS
PostPosted: Sat Nov 12, 2011 12:06 
User avatar
Full of plumptiousness

Joined: 30th Mar, 2008
Posts: 799
Location: Just left of perfection
I know a little bit of HTML and have created basic sites using tables but it's frustrating.

What is the best means to learn layout and positioning using CSS?

_________________
Malc


Top
 Profile  
 
 Post subject: Re: CSS
PostPosted: Sat Nov 12, 2011 12:22 
User avatar

Joined: 30th Mar, 2008
Posts: 16641
Just get stuck in and expect a fair bit of utter tedium, trial and error as you try to get it to work completely consistently (saying that it's been a couple of years since I've done all that much, things might have improved a bit). I guess start with a look at this, though:

http://www.w3.org/TR/CSS2/box.html


Top
 Profile  
 
 Post subject: Re: CSS
PostPosted: Sat Nov 12, 2011 16:05 
User avatar
Full of plumptiousness

Joined: 30th Mar, 2008
Posts: 799
Location: Just left of perfection
I have learnt a bit and cobbled something together as a test.

Question: why is the image of a tree nacking everything up and not fitting perfectly over the div#bannerimg? I have defined the size of the div to be 498px wide and 99px tall as those are the dimensions of the image.

In the page

<div id="bannerimg">

<img src="http://www.hughpaterson.co.uk/hpbanner.jpg" width="498" height="99" alt=" a tree" border=0>

</div>

in the css

div#bannerimg {
background-color: #000000;
width:498px;
height:99px;
}

_________________
Malc


Top
 Profile  
 
 Post subject: Re: CSS
PostPosted: Sat Nov 12, 2011 17:05 
SupaMod
User avatar
Est. 1978

Joined: 27th Mar, 2008
Posts: 69725
Location: Your Mum
Hugh wrote:
Question: why is the image of a tree nacking everything up and not fitting perfectly over the div#bannerimg?

It should do: http://jsfiddle.net/Grimdotdotdot/7tuqt/

But in your code, you've got it next to another div that's floating, so some of its width is behind that floated div. Either increase the width of #bannerimg to make up the space (731px), or add 'float: left;' to #bannerimg too. Then, after the close of #bannerimg, put
Code:
<div style="clear: both"></div>
to make everything after it starts on a new line.

_________________
Grim... wrote:
I wish Craster had left some girls for the rest of us.


Top
 Profile  
 
 Post subject: Re: CSS
PostPosted: Sat Nov 12, 2011 17:06 
SupaMod
User avatar
Commander-in-Cheese

Joined: 30th Mar, 2008
Posts: 49244
Craig Grannell's written a good book on the subject.

_________________
GoddessJasmine wrote:
Drunk, pulled Craster's pork, waiting for brdyime story,reading nuts. Xz


Top
 Profile  
 
 Post subject: Re: CSS
PostPosted: Sat Nov 12, 2011 17:24 
User avatar
Full of plumptiousness

Joined: 30th Mar, 2008
Posts: 799
Location: Just left of perfection
Thanks Grim... that worked.

Craig Grannell done a poo. (I will look at his bookington).

_________________
Malc


Top
 Profile  
 
 Post subject: Re: CSS
PostPosted: Sat Nov 12, 2011 17:51 
SupaMod
User avatar
Est. 1978

Joined: 27th Mar, 2008
Posts: 69725
Location: Your Mum
You know how to use the 'inspect element' bit of your browser, right?

_________________
Grim... wrote:
I wish Craster had left some girls for the rest of us.


Top
 Profile  
 
 Post subject: Re: CSS
PostPosted: Sat Nov 12, 2011 17:57 
User avatar
Full of plumptiousness

Joined: 30th Mar, 2008
Posts: 799
Location: Just left of perfection
Um.

_________________
Malc


Top
 Profile  
 
 Post subject: Re: CSS
PostPosted: Sat Nov 12, 2011 19:18 
SupaMod
User avatar
Est. 1978

Joined: 27th Mar, 2008
Posts: 69725
Location: Your Mum
If you use Firefox, install Firebug. If not (or once you've done that), press F12 and a "magic bit" will appear at the bottom of the screen. You can choose page elements on the left, and on the right will be the CSS styles that make them. You can edit the styles live to test things out before you commit them to your CSS file.

I honestly don't know how I did web development without it.

_________________
Grim... wrote:
I wish Craster had left some girls for the rest of us.


Top
 Profile  
 
 Post subject: Re: CSS
PostPosted: Sat Nov 12, 2011 19:34 
User avatar
Full of plumptiousness

Joined: 30th Mar, 2008
Posts: 799
Location: Just left of perfection
Wonderful stuff.

May I ask another probably stupid question? I promise this is the last one. FOR NOWN.

Why is the content in my footer not centring properly?

_________________
Malc


Top
 Profile  
 
 Post subject: Re: CSS
PostPosted: Sat Nov 12, 2011 19:40 
SupaMod
User avatar
Est. 1978

Joined: 27th Mar, 2008
Posts: 69725
Location: Your Mum
Get rid of 'text-align: center' in the parent div and put 'margin: 8px auto;' on .footer .
8px is the margin above and below, and 'auto' will automatically center it.

_________________
Grim... wrote:
I wish Craster had left some girls for the rest of us.


Top
 Profile  
 
 Post subject: Re: CSS
PostPosted: Sat Nov 12, 2011 19:47 
SupaMod
User avatar
Est. 1978

Joined: 27th Mar, 2008
Posts: 69725
Location: Your Mum
Here are a few general handy hints, which you can ignore or take onboard as desired.

  • Use % for font sizes
  • Don't style on IDs (#something), style on classes
  • Use a reset to stop different browsers behaving differently. Yahoo's is good.
  • Get the hang of using more than one class per element, such as <div class="box right"></div> to put a border on a div and float it to the right.
  • Run it through a validator every now and again.

There's going to be arguments about the first two, reckon ;)

_________________
Grim... wrote:
I wish Craster had left some girls for the rest of us.


Top
 Profile  
 
 Post subject: Re: CSS
PostPosted: Sat Nov 12, 2011 19:50 
User avatar
Full of plumptiousness

Joined: 30th Mar, 2008
Posts: 799
Location: Just left of perfection
Hmm. That moved everything over to the left, albeit neatly, rather than putting it in the centre.

<div id="footer" align="center">

Seems to have resolved it.

_________________
Malc


Top
 Profile  
 
 Post subject: Re: CSS
PostPosted: Sat Nov 12, 2011 19:52 
SupaMod
User avatar
Est. 1978

Joined: 27th Mar, 2008
Posts: 69725
Location: Your Mum
Sorry, check the edit - you put 'margin: ?px auto' on the .footer class (ie. the paragraphs themselves). align="center" on the parent will work fine (although it isn't valid XHTML).

_________________
Grim... wrote:
I wish Craster had left some girls for the rest of us.


Top
 Profile  
 
 Post subject: Re: CSS
PostPosted: Sat Nov 12, 2011 19:55 
User avatar
Full of plumptiousness

Joined: 30th Mar, 2008
Posts: 799
Location: Just left of perfection
If I don't use valid XHTML will I be earmarked for destruction come the day the meek inherit the Earth?

It's taken me about 5 hours to do what you see on that page. I passed the 11+. I thought I was clever!

_________________
Malc


Top
 Profile  
 
 Post subject: Re: CSS
PostPosted: Sat Nov 12, 2011 20:17 
User avatar
Isn't that lovely?

Joined: 30th Mar, 2008
Posts: 11169
Location: Devon
When I was doing webstuff (about 6 years ago) I always did the 2nd one, much easier imo, I used px size for the font size tho.

Malc

_________________
Where's the Kaboom? I was expecting an Earth shattering Kaboom!


Top
 Profile  
 
Display posts from previous:  Sort by  
Reply to topic  [ 16 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Columbo and 0 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
You cannot post attachments in this forum

Search within this thread:
You are using the 'Ted' forum. Bill doesn't really exist any more. Bogus!
Want to help out with the hosting / advertising costs? That's very nice of you.
Are you on a mobile phone? Try http://beex.co.uk/m/
RIP, Owen. RIP, MrC. RIP, Dimmers.

Powered by a very Grim... version of phpBB © 2000, 2002, 2005, 2007 phpBB Group.