html怎么固定图片大小(html怎么设置图片的大小)-编程之家

html如何设置图片大小

方法1:按样式= & quot宽度:180px高度:100px & quot

<img src="" style="width:180px;height:100px"/>& ltimg src = & quot”style = & quot宽度:180px高度:100px & quot/& gt;

方法2:通过调用样式

& ltstyle type = & quottext/CSS & quot;& gt

。src img { width:180 px;高度:100px}

& lt/style & gt;

<img src="" class="srcImg"/>& ltimg src = & quot”class = & quotsrcImg & quot/& gt;

如果图片img外容器有设置宽度的话;可以设置为width:100%;如果图像img外容器具有设定的宽度;可以设置为宽度:100%;