的width和height属性用来指定图像的宽度和高度。
默认情况下,这些属性的值以像素为单位进行解释。
例试试这个代码»
<img src="kites.jpg" alt="Flying Kites" width="300" height="300">
<img src="sky.jpg" alt="Cloudy Sky" width="250" height="150">
<img src="balloons.jpg" alt="Balloons" width="200" height="200">
您也可以使用该style属性指定图像的宽度和高度。由于内联样式具有最高优先级,因此可以防止样式表意外更改图像大小。
例试试这个代码»
<img src="kites.jpg" alt="Flying Kites" style="width: 300px; height: 300px;">
<img src="sky.jpg" alt="Cloudy Sky" style="width: 250px; height: 150px;">
<img src="balloons.jpg" alt="Balloons" style="width: 200px; height: 200px;">
注意:最好同时指定图片的width和height属性,以便浏览器可以在下载图片之前为其分配足够的空间。否则,图像加载可能会导致您的网站布局失真或闪烁。
如需转载,请注明文章出处和来源网址:http://www.divcss5.com/html/h60829.shtml