【实习第十天】图标字符&轮播图

1.图标字体

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <!-- 引入线上版本  跟上面的线下版本引入一个就可以了-->
    <!-- <link rel="stylesheet" href="https://at.alicdn.com/t/c/font_3797640_42r1d8h61fk.css" /> -->
    <!-- 引入线下版本  下载下来,如果没有网也是可以生效的 -->
    <link rel="stylesheet" href="./font_3797640_f35uft3b4bi/iconfont.css">
    <style>
      i.ss{
        font-size: 50px;
        color: red;
      }
      i.ss:hover{
        color: hotpink;
      }
      span.s1{
        font-size: 50px;
        color: green;
      }
      .s2{
        font-size: 100px;
        color: indigo;

      }
      p::before{
        content: "\eacc";
        font-family: 'iconfont';
      }
    </style>
  </head>
  <body>
    <!-- 第一种方式  转义字符形式  &实体的名字;  
        注意:一定要加公有的iconfont类名
    -->
    <i class="iconfont ss">&#xe8d6;</i>
    <span class="iconfont s1">&#xe601;</span>

    <!-- 第二种方式  类名形式 (常用)-->
     <i class="iconfont icon-shangjiantou s2"></i>
     <i class="iconfont icon-24gf-cartFull7 ss"></i>

    <!--第三种方式 伪类 (了解)-->
    <p>葬便治未,文使谢你。</p>
  </body>
</html>
<!--  
 图标字体(iconfont)
    网页中会有很多小的图片,例如,购物车,小箭头,定位等,
    这些内容可以直接用图片代替,但图片一般都是比较大的,而且修改起来也不方便
    所以可以直接使用图标字体,把它们就当成字体,可以用字体相关的样式,去修改
    图标字体,例如可以改变大小,颜色。

  图标字体在一些大的框架系统里,或者一些大的网站,很多大牛都已经归纳好,那我们
  直接使用即可,使用的方式方法大同小异。
    目前只要掌握一到两个网站即可
    阿里巴巴矢量图标库 https://www.iconfont.cn/

    使用图标库
      第一步:选择你需要的图标
      第二步:将你选中图标对应的css文件引入到你的html文件当中
            css文件可以线上版本,也可以下载下来,引入线下版本
      第三步:在结构中可以通过不同的使用方式,显示在页面中

 -->

2.层级

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title></title>
   <!-- 
知识点1:z-index
如果希望一个元素盖住另一个元素,那么我们就可以提高元素的层级
使用z-index样式,样式值:是一个正整数,值越大,层级越高,越能够显示在最上面
注意点:
    1、z-index,默认值是0
    2、z-index的使用前提是必须开启定位
    3、父元素的层级再高,也不会盖住子元素
知识点2:opacity  设置元素的透明度
          样式值:0-1之间,0是透明,1是不透明
       rgba也可以设置透明度
       transparent 可以设置透明效果
      -->
    <style type="text/css">
      .box1 {
        width: 200px;
        height: 200px;
        background-color: red;
        z-index: 20;
      }
      .box2 {
        width: 200px;
        height: 200px;
        /* background-color: rgba(255, 255, 0,.5); */
        background-color: transparent;
        opacity: 0.5;
        position: relative;
        left: 100px;
        top: -100px;
        z-index: 10;
      }
      .box3 {
        width: 200px;
        height: 200px;
        background-color: yellowgreen;
        position: relative;
        left: 200px;
        top: -200px;
        z-index: 11;
      }

      .box4 {
        width: 200px;
        height: 200px;
        background-color: orange;
        position: relative;
        z-index: 99;
      }

      .box5 {
        width: 100px;
        height: 100px;
        background-color: skyblue;
        position: relative;
        z-index: 0;
      }
    </style>
  </head>
  <body>
    <div class="box1">1</div>
    <div class="box2">2</div>
    <div class="box3">3</div>

    <!-- <div class="box4">
      4
      <div class="box5">5</div>
    </div> -->
  </body>
</html>

3.透明效果

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <!-- 面试题:opacity、rgba、transparent
           都可以设置透明的时候,几者的区别是什么? 
    1、  opacity是样式名,通过样式值的不同设置透明效果
  rgba、transparent是样式值,必须跟在特定的样式名后,才可以设置透明效果
  2、opacity可以给任何元素设置透明效果,就像在元素前面加一个模糊镜子一样
  rgba、transparent只能给背景色,颜色等特定的元素设定
  3、opacity具有继承性,rgba、transparent不具有继承
    -->
  <body>
    <!-- 用opacity设置透明度 -->
    <p style="background-color: red; opacity: 0.6">
      (3)这是一个p标签,颜色red,opacity值为0.6
      <span style="background-color: green"> 这是一个span标签,颜色green,opacity未设置 </span>
    </p>
    <!-- 用rgba设置透明度 -->
    <p style="background-color: rgba(255, 0, 0, 0.6)">
     (3)这是一个p标签,颜色red,透明度为0.6
      <span style="background-color: green">(这是一个span标签,颜色green,透明度未设置)</span>
    </p>
  </body>
</html>

4.轮播图写法-float

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <!-- 拓展:利用锚点功能或者其他方式,纯css实现图片切换 -->
    <style>
      *{
        padding: 0;
        margin: 0;
        list-style: none;
        text-decoration: none;
      }
      #wrap{
        width: 590px;
        height: 470px;
        margin: 50px auto;
        /* border: 10px red solid; */
        overflow: hidden;
        position: relative;
      }
      img{
        vertical-align: middle;
      }
      .imgs{
        width: 2950px;
      }
      .imgs>img{
        float: left;
      }
      .piont{
        position: absolute;
        left: 30px;
        bottom: 20px;
      }
      .piont>a{
        display: inline-block;
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background-color: rgb(243,206,139);
        margin: 0 3px;
        border: 2px solid transparent;
        /* 背景色只到内容区,边框没有背景 */
        background-clip: content-box;
      }
      .piont>a:hover{
        background-color: #fff;
        border: 2px solid rgb(100,100,109);
      }
    </style>
  </head>
  <body>
    <!-- 
     手写轮播图两种写法(结合js)
       1、float
       2、定位方式
    -->
    <!--3、swiper插件一种写法 (会引用,会修改即可) -->
    <!-- 轮播图 -->
    <div id="wrap">
      <!-- 图片 -->
      <div class="imgs">
        <img src="./img/1.jpg" alt="">
        <img src="./img/2.jpg" alt="">
        <img src="./img/3.jpg" alt="">
        <img src="./img/4.jpg" alt="">
        <img src="./img/5.jpg" alt="">
      </div>
      <!-- 小圆点 -->
      <div class="piont">
        <a href="#"></a>
        <a href="#"></a>
        <a href="#"></a>
        <a href="#"></a>
        <a href="#"></a>
      </div>
      <!-- 上一张下一张 -->
      <div>
        <span></span>
        <span></span>
      </div>
    </div>


  </body>
</html>

5.轮播图写法-定位

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      *{
        padding: 0;
        margin: 0;
        list-style: none;
        text-decoration: none;
      }
      #wrap{
        width: 590px;
        height: 470px;
        margin: 50px auto;
        border: 10px red solid;
        position: relative;
      }
      img{
        vertical-align: middle;
      }
      /* .imgs{
      } */
      .imgs>img{
        position: absolute;
      }
      .imgs>img:nth-child(4){
        z-index: 3;
      }
      .piont{
        position: absolute;
        left: 30px;
        bottom: 20px;
        z-index:99;
      }
      .piont>a{
        display: inline-block;
        width: 10px;
        height: 10px;
        border-radius: 50%;
        background-color: rgb(243,206,139);
        margin: 0 3px;
        border: 2px solid transparent;
        /* 背景色只到内容区,边框没有背景 */
        background-clip: content-box;
      }
      .piont>a:hover{
        background-color: #fff;
        border: 2px solid rgb(100,100,109);
      }
    </style>
  </head>
  <body>
    <!-- 
     手写轮播图两种写法(结合js)
       1、float
       2、定位方式
    -->
    <!--3、 swiper插件一种写法 (会引用,会修改即可) -->
    <!-- 轮播图 -->
    <div id="wrap">
      <!-- 图片 -->
      <div class="imgs">
        <img src="./img/1.jpg" alt="">
        <img src="./img/2.jpg" alt="">
        <img src="./img/3.jpg" alt="">
        <img src="./img/4.jpg" alt="">
        <img src="./img/5.jpg" alt="">
      </div>
      <!-- 小圆点 -->
      <div class="piont">
        <a href="#"></a>
        <a href="#"></a>
        <a href="#"></a>
        <a href="#"></a>
        <a href="#"></a>
      </div>
    </div>


  </body>
</html>

6.轮播图写法-swiper

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <!--swiper官网:
     https://www.swiper.com.cn/index.html -->
    <!-- 第一步 1引入swiper里面的css文件 -->
    <link rel="stylesheet" href="./swiper/swiper-bundle.css" />
    <style>
      /* 第三步:修改轮播图swiper的大小  (可选) */
      .swiper {
        width: 590px;
        height: 480px;
        margin: 50px auto;
      }
      /*  
        如果要更改轮播图的样式,
          第一种方式可以直接选中对应的类名,进行修改
          第二种方式:直接css文件修改(不推荐使用)
       */
      .swiper-pagination-bullet{
        background-color: turquoise;
        width: 20px;
        height: 20px;

      }
    </style>
  </head>
  <body>
    <!-- 第二步:写html的结构 -->
    <div class="swiper">
      <!-- 图片 -->
      <div class="swiper-wrapper">
        <div class="swiper-slide">
          <img src="./img/1.jpg" alt="" />
        </div>
        <div class="swiper-slide">
          <img src="./img/2.jpg" alt="" />
        </div>
        <div class="swiper-slide">
          <img src="./img/3.jpg" alt="" />
        </div>
      </div>
      <!-- 如果需要分页器  小圆点  -->
      <div class="swiper-pagination"></div>

      <!-- 如果需要导航按钮  上一张  下一张 -->
      <div class="swiper-button-prev"></div>
      <div class="swiper-button-next"></div>
    </div>

    <!-- 第一步 2引入对应的js文件 -->
    <script src="./swiper/swiper-bundle.js"></script>
    <!-- 第四步:初始化swiper -->
    <script>
      var mySwiper = new Swiper(".swiper", {
        // autoplay: {//设置自动切换,可以更改切换时间
          // delay: 2000,
        // },
        loop: true, // 循环模式选项
        effect: 'cards',//设置切换的方式

        // 如果需要分页器
        pagination: {
          el: ".swiper-pagination",
          clickable :true,//设置小圆点点击切换图片
        },

        // 如果需要前进后退按钮
        navigation: {
          nextEl: ".swiper-button-next",
          prevEl: ".swiper-button-prev",
        },
      });
    </script>
  </body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值