...

View Full Version : <hx> with images



fallinghawks
05-18-2005, 07:36 PM
Hello,
Can I define headings h1, h2, etc as having an image as well as text, just automatically? Sort of like the way they transform li bullets into images, but with hx instead? In my websearching I haven't been able to find a how-to.

I tried:

H1 {
font-size: 190%;
color: black;
background-image: url(images/tri.gif);
background-repeat: no-repeat;
padding-left: 20px;
}

but it doesn't seem to bring up the image, just does the 20px indent for

<h1>This is a title</h1>

Do I have to reference an image with every heading to get the same effect? Or am I missing something?

MattyUK
05-18-2005, 07:59 PM
Assuming your code it was a copy and paste. It works for me with a different image. I did drop H to h however. try "h1 {..." insted of "H1 {..."

I dont recall if it is case sensitive but it is worth a shot just in case.

If you still have problems can we see the page it is up in.

MattyUK

AaronW
05-18-2005, 08:16 PM
Use 'h1 {' instead, and assuming your image actually exists, it should work fine. Also, you may wish to use 'background-position: center left' too.

mstyle
05-18-2005, 09:07 PM
Another thing that bugged me occaisionally at the beginning of doing css. Imagepaths are relative to the location of the stylesheet.

so :

index.html

-includes
-images
+--your image is here
-css
+--your stylesheet is here


When you include the stylesheet in the index.html the imagepath inside the css would be ' background : url(../images/yourimage.png)'.

Just a tiny reminder.

AaronW
05-18-2005, 09:12 PM
That's why when writing global stylesheets you might as well use paths relative to the root:


<link ... href="/style.css">
...
background-image: url(/images/bg.jpg);

This way, no matter where you call it from, it's always going to look in the same spot.

Not an option for people whose sites are something.com/something, though. However, mod_rewrite can solve the issues around that.

fallinghawks
05-18-2005, 09:36 PM
Ah. The infamous case sensitivity. That did it.

Aaron sd:
> Not an option for people whose sites are something.com/something, though. However, mod_rewrite can solve the issues around that.

And that's what the site in question is, unfortunately. Thanks for the tip on mod_rewrite, I'll explore it and see what it's about.

mstyle sd:
>Imagepaths are relative to the location of the stylesheet.

Found that out the hard way... :D

Aaron, Matty, mstyle: You guys have come through for me again. Thanks, experts!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum