Css一些技巧【整理】

來源:互聯網
上載者:User

Css固定表格的表頭(向下拉捲軸的時候表頭固定不動)

.headLock

{

     top: expression(this.offsetParent.scrollTop); 

     position:relative;

}

Css固定表格的左列(向右拉捲軸的時候某列不變)

.leftLock

{

     left: expression(this.offsetParent.scrollLeft); 

     position:relative;

}

//應用的時候將該css加到對應的元素即可

根據層級的關係可以動態地添加offsetParent

如:

this.offsetParent.offsetParent.scrollLeft

this.offsetParent.offsetParent.offsetParent.scrollLeft

Css裡加js事件

td

  background-color:#ffffff;

  onmouseover:  expression(onmouseover=function (){this.style.borderColor ='blue';this.style.color='red';this.style.backgroundColor ='yellow'});

  onmouseout:  expression(onmouseout=function (){this.style.borderColor='';this.style.color='';this.style.backgroundColor =''});

}

Css控制文本超出範圍時顯示省略符號

div {

text-overflow:ellipsis;

width:200px;

white-space:nowrap;

overflow:hidden;

}

<div>這段文本肯定是超出了200px的範圍了,如果white-space:nowrap不加上去就沒有效果了,因為這樣會自動換行;overflow:hidden不加就不能隱藏超過的部分,也沒有效果;text-overflow:ellipsis是指省略部分要不要顯示省略符號text-overflow:clip是不顯示</div>

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.