zoukankan      html  css  js  c++  java
  • 每日思考(2020/07/11)

    题目概览

    • 在a标签上的四个伪类书写顺序是什么?
    • 对!important的理解,一般在哪些场景使用?
    • 写一个方法随机生成指定位数的字符串

    题目解答

    在a标签上的四个伪类书写顺序是什么?

    • link:未访问

    • visited:已访问

    • hover:鼠标悬停

    • active:鼠标点击瞬间

      a:link{color:black;}
      a:visited{color:gray;}
      a:hover{color:red;}
      a:active{color:blue;}
      

    对!important的理解,一般在哪些场景使用?

    • !important 可以让样式的特指度最高,覆盖任何样式,而且本身不可被覆盖。

    • 一般场景就是用来强制覆盖其他样式,用的比较少,不建议使用,因为别人没法覆盖这个样式,维护性比较低。

      p { text-indent: 1em ! important }
      p { font-style: italic ! important }
      p { font-size: 18pt }
      p { text-indent: 1.5em}
      p { font: normal 12pt sans-serif}
      p { font-size: 24pt }
      /* 在这些规则中 未被覆盖的有: */
      p { text-indent: 1em ! important }
      p { font-style: italic ! important }
      p { font-size: 24pt }
      

    写一个方法随机生成指定位数的字符串

    /**
     * getRandomString 随机生成指定位数的字符串
     * @param {number} length :字符串
     * @return {string}
     */
    function getRandomString(length) {
        let str = Math.random().toString(36).substr(2);//36进制从0-9a-z
        if (str.length >= length) {//随机数大于指定位数,则截取
            return str.substr(0, length)
        }
        str += getRandomString(length - str.length);//递归生成指定位数
        return str
    }
    
    let reStr = getRandomString(10);
    console.log(reStr); //no56569irw
    
  • 相关阅读:
    Mysql 怎么限制 IP 访问?
    LA2965 n个数中选出最多个数异或和为0
    UVALive 2678 大于s的最短子序列和
    UVA 1193 区间相关(greedy)
    UVA 11992 线段树
    UVA 1400 线段树
    NBUT 1120 线段树
    最大连续区间和的算法总结(转)
    hiho 1015 KMP
    hiho#1128 : 二分·二分查找
  • 原文地址:https://www.cnblogs.com/EricZLin/p/13286413.html
Copyright © 2011-2022 走看看