![]() |
Resize image with CSS, without CSS3?
For compatibility reasons, I want to steer clear of of CSS3.
I've defined the <h1> tag in the stylesheet to have a background image. I tried giving this a go in its own <div>, to no avail. The HTML has the <h1> tag nested in a <div> tag, but instead of the image displaying, it just collapses down to 5px, the padding of the header. These are two separate issues: 1. The image isn't displaying 2. I'd like for the image to fill the <h1> box, which in turn fills part of the header. I know I didn't write this in the most readable fashion, so if a copy-paste of the CSS and HTML is necessary, I can provide it. |
Put a fixed height on the h1 tag? Browser won't expand the box for background image.
|
you can also define the height and/or width for the image itself
Code:
<div> |
Thank you both for your replies.
Quote:
Code:
<div id="headContainer"Code:
#headContainer { |
An example without explicit height, if the img is next to your content:
Code:
#head {Now if it truly is a background image, where text or other content needs to go over it, I'd just specify the height. |
It's not a background image, but in my reading, I was given the impression this was the only practical way to manipulate without making use of CSS3.
Right now I'm mainly stuck on why the box collapses in and the image isn't visible. Doesn't the box automatically know it's there? It's nested in the div that is the box. |
can you post some of the code that you are using right now?
|
i wouldn't muck with the h1 size if it's not necessary. i would include an additional div with a static height. inside that put the h1 and the image. you only need h1 if you are putting text there, if it's only the image forget the h1 and put the image directly in the sized div.
|
I posted some code in post #4, but here's more if it's needed.
CSS: Code:
#center {Code:
<body> |
This is pretty informative:
CSS Wizardry After reading that, I'll probably end up using <img>. I think in some way I always saw this as the only proper solution. I do want to see if this can work though, and moreover I'd like to understand why <h1> doesn't recognize an image is there (which may be a limitation of the markup). In other words, not solved yet, but close! Additional reference: CSS Tricks |
well h1 is a designator for text headers, it was never meant to contain images. the only time i can think of that it MIGHT be necessary is for bullet point images, but you should do that with a ul anyway.
h1 is for text, not images. |
Quote:
|
yeah especially google, don't try and trick google because they are smart and they'll catch you.
|
| All times are GMT. The time now is 09:09 AM. |
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.