简体   繁体   English

将html / css图片缩放为不同的屏幕尺寸?

[英]Scaling html/css images for different screen sizes?

First time user, with a simple but frustrating problem. 初次使用的用户,有一个简单但令人沮丧的问题。

I am a new web coder, designing my website (austinwoehrle.net) 我是新的网络编码人员,正在设计我的网站(austinwoehrle.net)

I am trying to make the banner of Seattle scale with my darker background, but if I zoom in, it breaks out of the div. 我正在尝试使用较暗的背景使西雅图的横幅标尺缩放,但如果放大,它将脱离div。

On smaller monitors the image will be too large to fit in the darker background. 在较小的显示器上,图像太大,无法适合较暗的背景。

I have already set the width to 100% and have tried a lot of trouble shooting! 我已经将宽度设置为100%,并尝试了很多麻烦解决方法!

Thanks for the help! 谢谢您的帮助! Again, my website is http://www.austinwoehrle.net/homepage.html 同样,我的网站是http://www.austinwoehrle.net/homepage.html

At the moment you have this: 目前,您有以下内容:

<div id="seattle" alt="test">
    <img src="seattle.jpg" width="620" height="210"> 
</div>

Change the width of your image to width="100%" . 将图像的宽度更改为width="100%" This may then be slightly wider than you want it, so you will want to add margin or padding to the containing seattle div on line 126 of mystyle.css 那么这可能不是你想要它略宽,所以你要保证金或填充添加到含seattle DIV上的126线mystyle.css

width:80%;
margin:0 10%;

Then alter your image to have a width of 100% and remove the height. 然后将图像更改为100%的宽度,并删除高度。

<img src="seattle.jpg" width="100%"> 

Notes 笔记

 margin:0 10%;
 //is equal to writing
 margin-top:0;
 margin-right:10%;
 margin-bottom:0;
 margin-left:10%;

Check out this site for information on how to write this. 请访问此站点以获取有关如何编写此信息的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM