国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 開(kāi)發(fā) > CSS > 正文

CSS的expression判斷表達(dá)式設(shè)置input樣式

2024-07-11 09:04:20
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

武林網(wǎng)(www.survivalescaperooms.com)文章簡(jiǎn)介:用CSS的expression判斷表達(dá)式設(shè)置input樣式,簡(jiǎn)單,輕量級(jí)。缺點(diǎn)在于expression判斷表達(dá)式FireFox是不支持的。

  用CSS的expression判斷表達(dá)式設(shè)置input樣式,簡(jiǎn)單,輕量級(jí)。缺點(diǎn)在于expression判斷表達(dá)式FireFox是不支持的。致命的是只能區(qū)分出一個(gè)(例如例子中就只能區(qū)分出text文本框),不要試圖設(shè)置多個(gè)…

  代碼:

<!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" >
<head>
    <title></title>
    <meta name="Author" content="JustinYoung"/>
    <meta name="Keywords" content=""/>
    <meta name="Description" content=""/>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <style type="text/css">
    input
    {
    background-color:expression(this.type=="text"?'#FFC':'');
    }
    </style>
</head>

<body>
<dl>
<dt>This is normal textbox:<dd><input type="text" name="">
<dt>This is normal button:<dd><input type="button" value="i'm button">
</dl>
</body>
</html>


  另一種方法:

input{
    zoom: expression(function(ele){(ele.className)?ele.className+=" "+ele.type:ele.className=ele.type; ele.style.zoom = "1";}(this));
}


  1、將 input 的屬性取出來(lái),賦給 className。
  2、對(duì)于 expression,這里使用一個(gè)無(wú)關(guān)緊要的屬性(此處是zoom)來(lái)觸發(fā),處理完需要做的事情之后,再將此屬性覆蓋掉以解決 expression 不斷執(zhí)行的效率問(wèn)題。

  代碼:

<!--[if lt IE 7]>

<style type="text/css" media="screen">
input{ 
zoom: expression(function(ele){(ele.className)?ele.className+=" "+ele.type:ele.className=ele.type; ele.style.zoom = "1";}(this));
}
input.text{
border: 1px solid; border-color: #CCC #EEE #EEE #CCC;
background: #F5F5F5;
}
input.password{
border: 1px solid; border-color: #CCC #EEE #EEE #CCC;
color: #000; background: #F5F5F5;
width: 50px;
}
input.button{
border: 1px solid; border-color: #EEE #CCC #CCC #EEE;
color: #000; font-weight: bold; background: #F5F5F5;
}
input.reset{
border: 1px solid; border-color: #EEE #CCC #CCC #EEE;
color: #666; background: #F5F5F5;
}
</style>
<![endif]-->

<style type="text/css" media="all">
input[type="text"]{
border: 1px solid; border-color: #CCC #EEE #EEE #CCC;
background: #F5F5F5;
}
input[type="password"]{
border: 1px solid; border-color: #CCC #EEE #EEE #CCC;
color: #000; background: #F5F5F5;
width: 50px;
}
input[type="button"]{
border: 1px solid; border-color: #EEE #CCC #CCC #EEE;
color: #000; font-weight: bold; background: #F5F5F5;
}
input[type="reset"]{
border: 1px solid; border-color: #EEE #CCC #CCC #EEE;
color: #666; background: #F5F5F5;
}
</style>
</head>
<body>
<input type="text" name="xx" />
<input type="password" name="yy" />
<input type="checkbox" name="oo" />
<input type="radio" name="pp" />
<input type="button" name="qq" value="button" />
<input type="reset" name="oo" value="reset" />
</body>
</html>

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 青神县| 胶南市| 钦州市| 福清市| 定南县| 丹江口市| 太康县| 蒙自县| 锡林浩特市| 拜泉县| 喀喇沁旗| 沛县| 滕州市| 焉耆| 曲松县| 宾川县| 尤溪县| 北流市| 交口县| 邢台县| 彩票| 海阳市| 漠河县| 咸丰县| 湖州市| 林州市| 昌图县| 萍乡市| 湖南省| 新邵县| 峨眉山市| 博兴县| 乌拉特前旗| 阜南县| 南涧| 松桃| 泰安市| 新平| 富阳市| 秦皇岛市| 龙川县|