zoukankan      html  css  js  c++  java
  • less嵌套规则

    嵌套,是less里面最有意思的小东西,比如说我们经常性的去写一些列表性的东西
    html
    <ul class="list">
        <li><a href="#">links</a><span>2018-07-16</span></li>
        <li><a href="#">links</a><span>2018-07-16</span></li>
        <li><a href="#">links</a><span>2018-07-16</span></li>
    </ul>
    less
    /*
    一般这么写
    .list{}
    .list li{}
    .list a{}
    .list span{}
    */
    .list{
      width:600px;
      margin: 30px auto;
      padding:0;
      list-style: none;
    
      li{
        height: 30px;
        line-height: 30px;
        background-color: pink;
        margin-bottom:5px;
      }
      a{//不要写在li里面,尽量避免嵌套层级过深
        float: left;
      }
      span{
        float: right;
      }
    }
    =>
    /*
    一般这么写
    .list{}
    .list li{}
    .list a{}
    .list span{}
    */
    .list {
      width: 600px;
      margin: 30px auto;
      padding: 0;
      list-style: none;
    }
    .list li {
      height: 30px;
      line-height: 30px;
      background-color: pink;
      margin-bottom: 5px;
    }
    .list a {
      float: left;
    }
    .list span {
      float: right;
    }
    除了这个,它还提供一个更好玩的小东西,加hover的时候之前这样写
    /**
    .list a{}
    .list a:hover{}
    */
    .list{
      width:600px;
      margin: 30px auto;
      padding:0;
      list-style: none;
     
      a{
        float: left;
        //& 代表上了一层的选择器
        &:hover{
          color:red;
        }
      }
    }
    =>
    /**
    .list a{}
    .list a:hover{}
    */
    .list {
      width: 600px;
      margin: 30px auto;
      padding: 0;
      list-style: none;
    }
    .list a {
      float: left;
    }
    .list a:hover {
      color: red;
    }
    用起来还是蛮方便的
  • 相关阅读:
    ubuntu lock
    ubuntu 源
    ubuntu server版 ssh配置有时没有sshd_config文件或者空文件的情况
    pip3 install tensorflow==2.2
    tensorflow安装提示load 失败
    wXgame上某游戏封包分析
    lazarus 使用微软detour库 delphi
    dll函数导出
    Error: Duplicate resource: Type = 24, Name = 1, Lang ID = 0000
    Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 0.065 s <<< FAILURE!
  • 原文地址:https://www.cnblogs.com/wzndkj/p/9315837.html
Copyright © 2011-2022 走看看