繁体   English   中英

图片大小HTML和CSS

[英]Picture Size html and css

我有一个产品下拉菜单,我想要下拉菜单中每个选项旁边的产品图片。 我正在使用这条线来做到这一点

<img src="http://www.products.com/products/product1.png" 
alt="Product1" height="20" width="22" class="itemImg" 
style="float:right;position:absolute; top: 6px; right: 20px;">

但是,当复制此行以用于多种产品时,即使我给出了高度和宽度,并非所有图片看起来都一样。 是否可以立即使所有图片具有相同的大小,而不必修改每张图片的高度和宽度?

您的问题尚不清楚,您应该提供更多代码,但是可以! 您可以应用css制作相同大小的图片。 并删除position: absolute因为所有position: absolute将相互重叠。 我创建了一个片段检查,希望它能起作用。

 img.itemImg{width:150px; height:150px; background-color:green; position:relative !important;} 
 <img src="http://www.products.com/products/product1.png" alt="Product1" height="20" width="22" class="itemImg" style="float:right;position:absolute; top: 6px; right: 20px;"> <img src="http://www.products.com/products/product1.png" alt="Product1" height="20" width="22" class="itemImg" style="float:right;position:absolute; top: 6px; right: 20px;"> <img src="http://www.products.com/products/product1.png" alt="Product1" height="20" width="22" class="itemImg" style="float:right;position:absolute; top: 6px; right: 20px;"> <img src="http://www.products.com/products/product1.png" alt="Product1" height="20" width="22" class="itemImg" style="float:right;position:absolute; top: 6px; right: 20px;"> <img src="http://www.products.com/products/product1.png" alt="Product1" height="20" width="22" class="itemImg" style="float:right;position:absolute; top: 6px; right: 20px;"> <img src="http://www.products.com/products/product1.png" alt="Product1" height="20" width="22" class="itemImg" style="float:right;position:absolute; top: 6px; right: 20px;"> <img src="http://www.products.com/products/product1.png" alt="Product1" height="20" width="22" class="itemImg" style="float:right;position:absolute; top: 6px; right: 20px;"> <img src="http://www.products.com/products/product1.png" alt="Product1" height="20" width="22" class="itemImg" style="float:right;position:absolute; top: 6px; right: 20px;"> <img src="http://www.products.com/products/product1.png" alt="Product1" height="20" width="22" class="itemImg" style="float:right;position:absolute; top: 6px; right: 20px;"> <img src="http://www.products.com/products/product1.png" alt="Product1" height="20" width="22" class="itemImg" style="float:right;position:absolute; top: 6px; right: 20px;"> 

暂无
暂无

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

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