473,772 Members | 3,665 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

img: preserve aspect ratio but width and height="%"

hello,

i want to make website with a top navigation bar and one on the left.
so by using css i define three layers and everyone of them has length attr.
in percents.

but if i want to put (square) images in e.g. the top bar, which should fill
out the whole height of the bar, it depends on the screen resolution,
wether they look like square images or rectangles.

so my question is, how do i "tell" the browser that the image should fit 10%
of the screenresolutio n, but the image should be displayed squared, no
matter which resolution is set.
#img{
height=10%;
width= auto;
}
does NOT work

thank you
--
Georg Goerg
Jul 23 '05 #1
2 16640
In article <41************ ***********@tun ews.univie.ac.a t>,
e0******@studen t.tuwien.ac.at says...
of the screenresolutio n,
Screenresolutio n is irrelevant. You mean window size.
#img{
height=10%;
width= auto;
}
does NOT work


And should not. You have = where : should be. width:auto is not needed an
might even cause problems. Might be browser depended. If this was error
made while writing, you should see why URLs are nice.

#img {width:20%} has worked on some version of Opera and some version of
IE, IIRC.

--
Lauri Raittila <http://www.iki.fi/lr> <http://www.iki.fi/zwak/fonts>
Jul 23 '05 #2
Lauri Raittila wrote:
In article <41************ ***********@tun ews.univie.ac.a t>,
e0******@studen t.tuwien.ac.at says...
of the screenresolutio n,


Screenresolutio n is irrelevant. You mean window size.
#img{
height=10%;
width= auto;
}
does NOT work


And should not. You have = where : should be. width:auto is not needed an
might even cause problems. Might be browser depended. If this was error
made while writing, you should see why URLs are nice.

#img {width:20%} has worked on some version of Opera and some version of
IE, IIRC.

yeah i know, i just typed it wrong
i´ll try your solution, with just one attribute (width, height)

thanks
--
Georg Goerg
Jul 23 '05 #3

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

Similar topics

15
122152
by: Gérard Talbot | last post by:
Hello all, I'd like to know and understand the difference between, say, <img src="/ImageFilename.png" width="123" height="456" alt=""> and <img src="/ImageFilename.png" style="width: 123px; height: 456px;" alt="">
3
11033
by: Lasse Edsvik | last post by:
Hello I was wondering if its possible to the "width" and "height" of a text when creating a pic from text. string sometext = "bla bla"; Font font = new Font("Verdana", 18); SolidBrush sb = new SolidBrush(Color.Red);
16
4480
by: Tantale | last post by:
I used this serviec to check my webpage http://www.jmrw.com/Abroad/Barcelone/index.htm Made with Dreamweaver 8. The result is 206 errors, most of them "end tag omitted, but OMITTAG NO was specified.". I don't understand this result. Should I modify something ? Thanks
3
5315
by: Phil Endecott | last post by:
Dear Experts, It looks as if the HTML4 spec does not define a meaning for empty height and width attributes in an IMG element. Moz seems to ignore them, while IE7 sets the dimension to 1 pixel (or something like that). I have a vague recollection that "" did have a defined meaning at some point in the past, but maybe I am mis-remembering. Can anyone confirm? I have encountered this in some third-party PHP code that I'm using on
7
9865
by: Christian Hackl | last post by:
Hi everyone, I've got a question about what makes the "img" element's width/height attributes valid HTML or XHTML. First of all, this is a rather theoretical question, but digging through the W3C HTML 4.01 standard and this group's archive didn't give me a satisfactory answer, so here we go: Is <img src="img.png" alt="" width="100px" height="100px"really valid?
4
23925
by: tswaters | last post by:
Alright, so generally I'm using document.createElement("IMG").... but, I've noticed something just recently that made me switch to "new Image()" What I'm doing is creating a photo gallery of sorts, where i basically want to supply a total # of images, rows/cols max thumb/full image and let the script do the work. The solution I've opted for is to load the images once and change their size / position / visibility to show "thumb galleries" or...
5
3086
by: enaz | last post by:
Ok, so, this is my first post, if there is any info i am leaving out please tell me this is the function: function mouseOver(c) { alert(c); <!-- just for debugging--> if (c.src == "red.jpg") {
0
10261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10104
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8934
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.