zoukankan      html  css  js  c++  java
  • css伪元素::before与::after

    伪元素前面一定是双冒号:: ,单冒号的是选择器。

    1、用来给元素前后添加新的元素。比如标题前面会有一个小方块,就可以通过‘::before ’来添加。

    .title::before{
    display: block; content:''; height:30px; 4px; background:#eee; }

     最重要的两个属性,一定要家display和content.

    2、用来添加图片

     <i class="icon-plane"></i>
    .icon-plane {
          display: inline-block;
          position: relative;
          width: 60px;
          height: 60px;
          border-radius: 50%;
          background: linear-gradient(to bottom right, #2ca0f7, #1e95ed);
          &::after {
            content: "";
            position: absolute;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
            background: url("./images/icon_plane.png") no-repeat;
          }
        }

     生成效果:

    注意的是:伪元素里一定要添加content: "",否则是没有图片的。

    3、清除浮动

  • 相关阅读:
    COGS 2104. [NOIP2015]神奇的幻方
    洛谷 P1387 最大正方形
    包和一些常用的模块
    模块
    模块的导入和使用
    函数迭代器与生成器
    函数的小知识
    函数的闭包和装饰器
    函数的进阶
    初识函数
  • 原文地址:https://www.cnblogs.com/qingshanyici/p/10171571.html
Copyright © 2011-2022 走看看