I’m new to stackoverflow.com and this is my first post so:
I want to have a h1-text with underline. This underline will be an image and it should have a fixed width of 420px. The text in h1 will often be wider than the 420px, but sometimes shorter. Now I know that these are the solutions to get the underline as an image, but how do I set the fixed width for the underline only?
h1 {
background-image:url('images/hrBg.jpg');
background-position: 0px bottom;
background-repeat: repeat-x;
}
Create the background image with the width of 420px.
Then use the following css
This will ensure that the background is shown only once to with of 420px. I have added the
min-widthproperty in case the content ofh1is smaller than 420px. Theno-repeatproperty ensures that the background is shown only once as we have set the length via the actual image.