473,473 Members | 1,857 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Image inside a box

Abs
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
Jul 21 '05 #1
1 3716

"Abs" <ab*@yahoo.com> wrote in message news:30*************@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%; }

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Raghavendra RAV | last post by:
Hi, I need to store an image from a Graphics object(.NET) inside a xml data island. Anyone might have came accross or have an idea how to do this. Please share. Thanks & Regards, Raghu, CSS...
3
by: Alberto | last post by:
I'm trying to load an image in a PictureBox but I want the PictureBox has always the same size and if the image is bigger, show a scrollBars. How can I do it? Thank you
12
by: Charlie King | last post by:
As I understand it, the use of FIR* to replace heading tags with images in visually enabled CSS browsers is now frowned upon on the basis that some screen readers will *nor* read back text that is...
2
by: sachaburnett | last post by:
Hi everyone! I'm new to Javascript and am finding so much useful information on this group, so thanks to you all! I have a question about preloading images for onmouseover/out effects and...
1
by: jalpa11 | last post by:
Hi all, I have one EMF image which I want to convert to BMP. I want to scale the BMP and want to display it in my viewport area. If scaled BMP doesn't fit inside the viewport area then I want to...
9
by: The Natural Philosopher | last post by:
Ok. what I want to do, is have pictures as BLOBS in a database. And show them onscreen. If I have a generic program called say - showpic.php - which is capable of spitting out an image...
3
by: crazychrisy54 | last post by:
Hi there I just wondered if there is any way using GD to insert a clickable button or some clickable text into a image? It is possible to create images for buttons but what if you want a...
4
by: =?Utf-8?B?YWxiZXJ0b3Nvcmlh?= | last post by:
Hi everydoby! I have an issue, I have an static image, and I need to write text inside it in runtime, but I don't know how! I can't use absolute position in atributtes style. Thanks.
5
by: Tea Maker | last post by:
Hello experts, I have an Ajax UpdatePanel inside my page. When I click on the "Change Image" button inside it, the image in that panel will change dynamically, based on an external XML file, that...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.