Help with sprites and CSS

Associate
Joined
20 Sep 2003
Posts
2,361
Location
Scotland
I am putting together a website for the first time in ages and want to do some simple rollovers. Doing some research I see this now done using sprites, my question is do all the buttons have to be the same size?

Here are the buttons I want to use and below is how I want to lay them out, can I use CSS to spread these buttons like shown on my mockup?

Site
http://rdoyle.info/

Sprite
http://rdoyle.info/buttons.png

Cheers
 
Soldato
Joined
3 Jun 2005
Posts
3,119
Location
The South
...my question is do all the buttons have to be the same size?
No but it makes life easier if you do use the same dimensions for your individual sprites and nav'container'.

Here are the buttons I want to use and below is how I want to lay them out, can I use CSS to spread these buttons like shown on my mockup?
Sure; you'd set the background positions accordingly to each nav'container'

However due to the simplicity of what you're wanting, it'd be easier to use text decoration/underline on the text or highlighting the bottom borders of the containers (could use spans if needing different colours) for the hover/click event.
 
Soldato
Joined
18 Oct 2002
Posts
2,910
Location
London
What font is it? You may be able to use it as a web font and it won't matter if the user doesn't have it on their machine or not.
 
Soldato
Joined
3 Jun 2005
Posts
3,119
Location
The South
If you're planning to use the font extensively on the site then, as Ekim mentions, it's worth finding out if it's available as a webfont (have a look on Google Fonts, Font Squirrel, Fonts.com etc) which you can 'import' via CSS.

As for using sprites, this (http://jsfiddle.net/rWfJp/) should get you started, although i suspect (i'm not a frontend dev) it's extremely crude and could be 'tarted' up.
 
Associate
OP
Joined
20 Sep 2003
Posts
2,361
Location
Scotland
If you're planning to use the font extensively on the site then, as Ekim mentions, it's worth finding out if it's available as a webfont (have a look on Google Fonts, Font Squirrel, Fonts.com etc) which you can 'import' via CSS.

As for using sprites, this (http://jsfiddle.net/rWfJp/) should get you started, although i suspect (i'm not a frontend dev) it's extremely crude and could be 'tarted' up.

Very nice..... thanks!
 
Associate
OP
Joined
20 Sep 2003
Posts
2,361
Location
Scotland
Thanks for all the help guys, managed to get it arranged the way I was aiming for though have a slight CSS issue with the text on the left column.

Any ideas why it isn't inline with the Services button?

http://rdoyle.info/
 
Joined
12 Feb 2006
Posts
17,316
Location
Surrey
you're padding on padding by the looks of it, and not aligning things/making the width the same on things. not had a look at your css, but it appears your header image isn't as wide as the site, so when things are left aligned they show further left then the center aligned header image.
 
Associate
Joined
12 Dec 2009
Posts
624
Location
Gloucester, UK
You could easily achieve that navigation with the use of no images at all. A quick inspection looks like there might be some div issues. Did you intend the wrapper only to be wrapping the header? I also note what you say about the main div not aligning with the header, this is just due to the widths of your columns. If you wanted any help, i can post up how I'd do it?

Also a note, I'd remove the inline style too, just to keep it clean!
 
Last edited:
Associate
Joined
12 Dec 2009
Posts
624
Location
Gloucester, UK
No problem, gimme 30 mins, when the wife's finished looking at holidays, i will post a link to some code that will hopefully help, ill try leave some notes as to why i do it the way i do :)
 
Associate
Joined
12 Dec 2009
Posts
624
Location
Gloucester, UK
Hey man, sorry for the delay. If you go to: http://jsfiddle.net/x7Jw9/1/ - You will see i've set it so your columns and header line up. Also changed your navigation to be a pure html/css solution - no imagery. The only thing missing is the font as i can't link this up via jsfiddle, but it works fine locally. You just need to download the fontface files from font squirrel here - I also removed the br and inline styles.

Other than that, made a few tweaks, nothing major. Personally if your going to follow a two column layout, or so, i would think about make a left / right column div which holds the widths and margins, then all you have to do is interchange further code within it's respective parent.

I wasn't sure if you're intention was to make the nav the same width as the left column, but i made it the width the website as this seemed more logical, but that can easily be changed back via the css and shouldn't break anything.

If I've missed anything let me know, or if you did want further help just look me up. You could look at making the telephone + email live text as well, this would mean you can attach a mailto: action on the email link. Although i appreciate i am going off your original question, apologies i am a geek.
 
Last edited:
Associate
OP
Joined
20 Sep 2003
Posts
2,361
Location
Scotland
Great work mate, I will take a look at this in more depth tomorrow as its a bit late on now but its looking great, really appreciate your help!

I assume I can use the same web font technique for the text on the phone number and email address etc?

Big thanks!!!
 
Back
Top Bottom