CSS Sprite
需要知道大图的网地,小图标在图上的位置偏移(写进css里的background-position要加负号),和大小。
<style>.icon {
background:url(background.png)
background-repeat:no-repeat
background-position:-25px -374px
height:16px
width:24px
}
</style>
<div class=".icon"></div>
img{-webkit-clip-path: polygon(0 0,100% 0,100% 40px,145px 40px,130px 60px,115px 40px,0 40px,0 0)
clip-path: polygon(0 0,100% 0,100% 40px,145px 40px,130px 60px,115px 40px,0 40px,0 0)
}
img标签内的图片不能自适应img标签大小。img标签语法:<img src="url" alt="some_text">
URL 指存储图像的位置,alt 属性用来为图像定义一串预备的可替换的文本。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf‐8">
<title>http://www.xinbiancheng.cn</title>
</head>
<body>
<h2>html图像标签怎么使用</h2>
<img src="pic.png" alt="Pulpit rock" width="304" height="228">
</body>
</html>
如果图像指定了高度宽度,页面加载时就会保留指定的尺寸。如果没有指定图片的大小,加载页面时有可能会破坏HTML页面的整体布局。