CSS中常用expression的例子

來源:互聯網
上載者:User

1.更改頁面所有的<a href ,要求target為_blank,新開啟一個視窗
<style>
A
{
target :expression(this.target="_blank");
}
</style>

2.消除頁面上的連結虛線框
<style type="text/css">
a {star : expression(onfocus=this.blur)}
</style>
3.用CSS自訂屬性Expression對錶格行間隔背景批量定義
<style type="text/css">
tr{ background-color:expression('#F8F8F8,#EFEFEF'.split(',')[rowIndex%2]); }
</style>
4.控制table的對齊
在css中定義一個偽類:
.myTableCenter{myalign:expression(this.align="right");}
在<table>中引用.myTableCenter樣式即可
5.依照瀏覽器的大小來安置一個元素的位置
.myclass {left: expression(document.body.offsetWidth - 110 + "px");}
6.區分唯讀文字框
<style>
input{background-color:expression((this.readOnly && this.readOnly==true)?"#f0f0f0":"")}
</style>
<INPUT TYPE="text" NAME="">
<INPUT TYPE="text" NAME="" readonly>
7.替換圖片CSS
#imgScript {   /*這裡使用對象ID來通配樣式, 也可以定義一個css函數*/
 star:expression(
    onmouseover = function()
    {
        /*替換圖片*/
        if(this.hover != null){
          this.name = this.src;
          this.src = this.src="/Files/BeyondPic/2006-5/29/0652912505890151.jpg", '_over.jpg');
          this.HasChg = 1;
       }
   },
   onmouseout = function()
  { 
       /*還原本來的圖片*/
     if(this.HasChg != null){
        this.src = this.name;
        this.HasChg = null;
    }
 }
)

}

相關文章

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.