样式css选择一张图片(包含所有图标集)里任意一个图标icon

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>animate</title>
    <style>
        i{ display: inline-block;width: 8px;height: 7px;background: url(images/public-24.png) no-repeat -99px 3px;}
    </style>
</head>
<body>
<i></i>
</body>
</html>

思路:i/s/b/div等等标签,设计其背景图片(即图标)如background: url(images/public-24.png) no-repeat -99px 3px。其中url(images/public-24.png) 表示图标集合路径、no-repeat不平铺、-99px 3px图标在图标集的位置,通过设置此坐标取得图标

注意:包含图标的标签如i(样式css 不设置display: inline-block;)可能会出图标无法显示。

猜你喜欢

转载自blog.csdn.net/qq_31935419/article/details/81099844
今日推荐