Html基础知识学习——css精灵(十五)

16 篇文章 1 订阅
12 篇文章 1 订阅

这里写自定义目录标题

定义

将网页用到的图片放在一张图片上,进行定位展示
优点:防止网页http请求次数过多,从而提高页面性能
缺点:降低开发效率。维护难度加大

示例一

使用图
在这里插入图片描述

网页制作图
在这里插入图片描述

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /* css精灵  :将网页用到的图片放在一张图片上
                        优点:防止网页http请求次数过多,从而提高页面性能
                     缺点:降低开发效率。维护难度加大*/
        div {
            width: 80px;
            height: 80px;
            background: url(bigptr.jpg) no-repeat;
            border: 10px solid #000;
            float: left;
            margin: 10px;
            display: inline;
        }

        .box1 {
            background-position: -151px -66px;
        }

        .box2 {
            background-position: -241px -118px;
        }

        .box3 {
            background-position: right top;
        }

      
    </style>
</head> 
<body>
    <div class="box1"></div>
    <div class="box2"></div>
    <div class="box3"></div>
   
</body>

</html>

示例二

用到图片
在这里插入图片描述
网页制作
在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style> 
      .box{width: 300PX;margin: 30px auto;} 
        .boxHead,.boxHeadL,.boxHeadR,.boxFoot,.boxFootL,.boxFootR{background: url(img/ico.gif) no-repeat;}
        .boxHead,.boxFoot{height: 9px;overflow: hidden;background-repeat: repeat-x;}
        .boxHeadL{background-position: 0 -9px;}
        .boxHeadR{height: 9px; background-position: right -18px;}
        .boxFoot{background-position: 0 -27px;}
        .boxFootL{background-position: 0 -36px;}
        .boxFootR{height: 9px;background-position: right -45px;}
        .boxc{border-left: 1px solid #e5e5e5;border-right: 1px solid #e5e5e5;}
  </style>
</head>
<body>
    <div class="box">
        <div class="boxHead">
            <div class="boxHeadL">
                <div class="boxHeadR"></div>
            </div>
        </div>
        <div  class="boxc"  >
            欣欣向荣<br/>
            欣欣向荣<br/>
            欣欣向荣<br/>
            欣欣向荣<br/>
            欣欣向荣<br/>
            欣欣向荣<br/>
            欣欣向荣<br/>
            欣欣向荣<br/>
            欣欣向荣<br/>
            欣欣向荣<br/>
            欣欣向荣<br/>
        </div>
        <div class="boxFoot">
            <div class="boxFootL">
                    <div class="boxFootR"></div>
            </div>
        </div>
    </div>
</body>
</html>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值