HTML幾個(gè)特殊的屬性標(biāo)簽的使用介紹

字號:


    在HTML中還有幾個(gè)容易讓我們遺忘的特殊的屬性標(biāo)簽,下面為大家詳細(xì)介紹下這幾個(gè)屬性在各個(gè)瀏覽器中的使用,為了能達(dá)到更好的兼容,建議web人員抽空看看
    以下幾項(xiàng)屬性對于瀏覽器的兼容很不好.
    1.transform:rotate(45deg)
    2.border-top-left-radius 該屬性允許您向元素添加圓角邊框
    3.border-radius 該屬性允許您向元素添加圓角邊框
    4.box-shadow 屬性向框添加一個(gè)或多個(gè)陰影
    5.text-shadow 屬性向文本設(shè)置陰影
    6.transition
    為了更好的兼容各個(gè)瀏覽器,需要加上前綴.
    -o- /*Opera瀏覽器*/
    -webkit- /*Webkit內(nèi)核瀏覽器 Safari and chrome*/
    -ms- /*IE 9*/
    -moz- /*Firefox瀏覽器*/
    1.transform:rotate(45deg)
    通過transform屬性使對象旋轉(zhuǎn),其中(45deg)是旋轉(zhuǎn)的角度
    transform:rotate(45deg);
    -ms-transform:rotate(45deg); /*IE 9*/
    -o-transform:rotate(45deg); /*Opera瀏覽器*/
    -webkit-transform:rotate(45deg); /*Webkit內(nèi)核瀏覽器 Safari and chrome*/
    -moz-transform:rotate(45deg); /*Firefox瀏覽器*/
    2.border-top-left-radius border-radius 該屬性允許您向元素添加圓角邊框
    前者可以選擇添加圓角邊框的位置
    border-top-left-radius,border-top-right-radius,border-bottom-left-radius,border-bottom-right-radius
    border-top-left-radius 該屬性允許您向元素添加圓角邊框,與border-radius一樣,只是可以控制需要添加圓角邊框的位置.
    3.box-shadow屬性向框添加一個(gè)或多個(gè)陰影,text-shadow屬性向文本設(shè)置陰影
    box-shadow: h-shadow || v-shadow || blur || spread || color || inset;
    屬性:水平陰影的位置 || 垂直陰影的位置 || 模糊距離 || 陰影尺寸 || 陰影顏色 || 將外部陰影(outset)改為內(nèi)部陰影
    box-shadow:1px 1px 3px #292929;
    text-shadow: h-shadow || v-shadow || blur || color;
    text-shadow: 0px -1px 0px #000;
    4.transition
    property || duration || timing-function || delay
    規(guī)定設(shè)置過渡效果的 CSS 屬性的名稱 || 規(guī)定完成過渡效果需要多少秒或毫秒 || 規(guī)定速度效果的速度曲線 || 定義過渡效果何時(shí)開始
    目前所有瀏覽器都不支持 transition 屬性。
    ease 默認(rèn)。動(dòng)畫以低速開始,然后加快,在結(jié)束前變慢.
    ease-in 動(dòng)畫以低速開始.
    ease-out 動(dòng)畫以低速結(jié)束
    ease-in-out 動(dòng)畫以低速開始和結(jié)束
    transition:background 5s ease;
    ONE EG:
    代碼如下:
    <html>
    <head>
    <style>
    div
    {
    width:100px;
    height:100px;
    background:blue;
    transition:width 2s;
    -moz-transition:width 2s; /* Firefox 4 */
    -webkit-transition:width 2s; /* Safari and Chrome */
    -o-transition:width 2s; /* Opera */
    }
    div:hover
    {
    width:300px;
    }
    </style>
    </head>
    <body>
    <div></div>
    <p>請把鼠標(biāo)指針移動(dòng)到藍(lán)色的 div 元素上,就可以看到過渡效果。</p>
    <p><b>注釋:</b>本例在 Internet Explorer 中無效。</p>
    </body>
    </html>
    TWO EG:
    代碼如下:
    <html>
    <head>
    <style>
    div
    {
    width:100px;
    height:100px;
    background:blue;
    transition-property:background;
    transition-duration:5s;
    /* Firefox 4 */
    -moz-transition-property:background;
    -moz-transition-duration:5s;
    /* Safari and Chrome
    -webkit-transition-property:background;
    -webkit-transition-duration:5s;*/
    transition:background 5s ease;
    /* Opera */
    -o-transition-property:background;
    -o-transition-duration:5s;
    }
    div:hover
    {
    background:red;
    }
    </style>
    </head>
    <body>
    <div></div>
    <p>請把鼠標(biāo)指針移動(dòng)到藍(lán)色的 div 元素上,就可以看到過渡效果。</p>
    <p><b>注釋:</b>本例在 Internet Explorer 中無效。</p>
    </body>
    </html>