web: image in css

Forum for anything hard- or software related.

Moderator: Moderators

Post Reply
blissard
tried to put the pin back in
Posts: 291
Joined: Tue Oct 07, 2003 5:47 pm
Location: no

web: image in css

Post by blissard »

hey, i'm trying to learn some css, and encountered a small problem.

how can i set an image in css with the class-command?

i.e:

Code: Select all

<img class="header">
in the php-file.

and then in the css-file: (this is the part where i got it wrong)

Code: Select all

.header {
image : url("gfx/header_01.gif");
}
hehehHEheheHheh GOGOGO Head shot !
NRGizeR
feels some chest pain
Posts: 695
Joined: Mon Aug 30, 2004 1:00 am
Location: fi
Contact:

Post by NRGizeR »

why use css for that?

Code: Select all

<img src="gfx/header_01.gif">
or if you want to do some funky stuff (such as adding borders, doing absolute placing etc) with css, use

Code: Select all

<img src="gfx/header_01.gif" class=header>
and add the stuff you want to the css file (ex border, top, left, position, etc) ...
NRGizeR
feels some chest pain
Posts: 695
Joined: Mon Aug 30, 2004 1:00 am
Location: fi
Contact:

Post by NRGizeR »

oh, and if you want to learn css properly there are great tutorials and a complete css2 reference at http://www.w3schools.com/css/default.asp
blissard
tried to put the pin back in
Posts: 291
Joined: Tue Oct 07, 2003 5:47 pm
Location: no

Post by blissard »

i know how to place an image, just not with css.

i want the page to change with different css-files, mainly colors, but also some images.

i used this one:

Code: Select all

<td class="td_border">
together with this one:

Code: Select all

.TD_BORDER  {
	background-image: url("gfx/border.gif");
}
which works fine..
hehehHEheheHheh GOGOGO Head shot !
NRGizeR
feels some chest pain
Posts: 695
Joined: Mon Aug 30, 2004 1:00 am
Location: fi
Contact:

Post by NRGizeR »

It sounds to me as if you've misunderstood the purpose of css somewhat, but I could be mistaken... try to read the reference/tutorials... those will help...
blissard
tried to put the pin back in
Posts: 291
Joined: Tue Oct 07, 2003 5:47 pm
Location: no

Post by blissard »

look, i'm putting as much as possible into the css-file. so if i make another css-file with changed colors, and changed images, the look of the page will change with it. kinda like a skin.

i just want to know how to set the src for an image through css, so if i have different src in different css-files, the img will change.
hehehHEheheHheh GOGOGO Head shot !
blissard
tried to put the pin back in
Posts: 291
Joined: Tue Oct 07, 2003 5:47 pm
Location: no

Post by blissard »

no matter, i used the picture as a tablecell-background, like i did with the border. but if anyone knows how to use it without a table, tell me :)
hehehHEheheHheh GOGOGO Head shot !
NRGizeR
feels some chest pain
Posts: 695
Joined: Mon Aug 30, 2004 1:00 am
Location: fi
Contact:

Post by NRGizeR »

if you would have checked the reference....... you would have realized that there is no (spoon)/image tag in css

you can however, do what I think you'd like to do with a <div> tag and a background-image entry in css, and if you want to use more "pure" css, I would suggest going down this path instead of using tables...
blissard
tried to put the pin back in
Posts: 291
Joined: Tue Oct 07, 2003 5:47 pm
Location: no

Post by blissard »

indeed, i certainly had a hard time finding one.

i'm such a sucker for tables, i fell in love with them many years ago. but we also hates them, yes, as they behave differently in firefox, opera and ie.
hehehHEheheHheh GOGOGO Head shot !
Guenhwyvar
is connecting
Posts: 15
Joined: Tue Jul 29, 2003 3:58 am
Location: it

Post by Guenhwyvar »

Do it with <div> and background-image.
Pantteli - Fear is how I fall...
impressiVe
found a way out
Posts: 207
Joined: Fri Oct 22, 2004 8:56 am
Location: de
Contact:

:))))

Post by impressiVe »

Wtf i thought you wanted to play counterstrike source xD.. Luck for you m8 ^^
Ohlolol fragged again :/
Post Reply