This is Interesting: Free Magazines for Graphics designers and webmasters
Home > Archive > Stylesheets > November 2004 > Image inside a box
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Image inside a box
|
|
|
| Hi!
I need to put an image inside a box, centering and resizing it to fit
the box. The box is positioned and sized in the page using percent
values. The problem is that I don't know how can I do it exactly.
This is the style code for the box:
..box {
top: 20%;
left: 20%;
width: 50%;
height: 50%;
}
This is the style code for the image:
..image {
text-align: center;
?????
}
I don't know how to center the image vertically and how to resize
it to fit the box mantaining its aspect ratio. Can someone
help me, please ?
Thanks in advance
--
Abs
| |
| Harlan Messinger 2004-11-22, 11:22 pm |
|
"Abs" <abs@yahoo.com> wrote in message news:305ugsF2s5h7eU1@uni-berlin.de...
> Hi!
>
> I need to put an image inside a box, centering and resizing it to fit
> the box. The box is positioned and sized in the page using percent
> values. The problem is that I don't know how can I do it exactly.
>
> This is the style code for the box:
>
> .box {
> top: 20%;
> left: 20%;
> width: 50%;
> height: 50%;
> }
>
>
> This is the style code for the image:
>
> .image {
> text-align: center;
> ?????
> }
>
> I don't know how to center the image vertically and how to resize
> it to fit the box mantaining its aspect ratio. Can someone
> help me, please ?
You can't specify both the height and the width AND then expect to preserve
the aspect ratio. They are mutually contradictory.
You don't need a box.
img { width: 50%; }
|
|
|
| | Copyright 2003 - 2008 forum4designers.com Software forum Computer Hardware reviews |
|