图片大小html和css

时间:2016-03-05 06:50:43

标签: html 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;">

然而,当复制此行以在多个产品中使用时,即使我给出高度和宽度,并非所有图片看起来都相同。是否可以立即使所有图片尺寸相同而不必修改每张图片的高度和宽度?

1 个答案:

答案 0 :(得分:0)

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

&#13;
&#13;
img.itemImg{width:150px; height:150px; background-color:green; position:relative !important;}
&#13;
<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;">
&#13;
&#13;
&#13;