常用css样式记录

123 阅读1分钟

选取某元素父元素的最后两个元素

> &:nth-last-child(-n+2){    
        border-bottom:none;
    }

超出两行隐藏出现省略号...

    {
            line-height: 14px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
     }

文本超出一行,则字体变小

  let timer=setInterval(() => {
            let f=document.getElementsByClassName('father')[0];
            let c=document.getElementsByClassName('child')[0];
            if (f&&c) {
                let fw=f.offsetWidth;
                let cw=c.offsetWidth;
                if (fw-cw<20) {
                    this.is9px=true;
                }
                clearInterval(timer);
            }
        }, 50);