[英]How to resize this image using simple HTML and CSS
I am trying to resize this responsive image with basic HTML and CSS. 我正在尝试使用基本的HTML和CSS调整此响应图像的大小。 It seems as though no matter what I do, nothing will alter the size.
似乎无论我做什么,都不会改变大小。 Is there something preventing it from being a larger image?
有什么阻止它变大的图像吗? I'm teaching myself how to create a webpage and will accept any advice given!
我正在教自己如何创建网页,并且会接受任何建议! Thanks!
谢谢!
HTML HTML
<ul id="gallery">
<li>
<a href="img/chicago.jpg">
<img src="img/chicago.jpg" alt="">
</a>
</li>
</ul>
CSS CSS
#gallery{
margin:0;
padding:0;
list-style: none;
}
#gallery li {
float: left;
position: relative;
left: 30%;
width: 70%;
margin: 2.5%;
background-color: #f5f5f5;
color: #bdc3c7;
}
The css properties max-width and max-height work great, but aren't supported by IE6 and I believe IE7. css属性的max-width和max-height效果很好,但是IE6不支持,我相信IE7。 You would want to use this over height / width so you don't accidentally scale an image up.
您可能希望在高度/宽度上使用它,以免意外放大图像。 You would just want to limit the maximum height/width proportionately.
您只想按比例限制最大高度/宽度。
CSS: CSS:
img
{
border:1px solid #000;
width:100%;/*adjust this value to your needs*/
max-width: 400px;/* so it wont get bigger and pixelated*/
height:auto;
}
HTML: HTML:
<a href="img/chicago.jpg">
<img src="img/chicago.jpg" alt="">
</a>
img { width: 100% }
您需要设置图像的宽度。
Make sure that the CSS you are writing isn't overwritten by other CSS. 确保您正在编写的CSS不会被其他CSS覆盖。 If another CSS files that is loaded later changes the image-size, the CSS you wrote prior will have no effect
如果稍后加载的另一个CSS文件更改了图像大小,则您之前编写的CSS将无效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.