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

首頁 > 開發 > CSS > 正文

CSS expression判斷表達式設置input樣式

2024-07-11 08:27:36
字體:
來源:轉載
供稿:網友
用CSS的expression判斷表達式設置input樣式,簡單,輕量級。缺點在于expression判斷表達式FireFox是不支持的。致命的是只能區分出一個(例如例子中就只能區分出text文本框),不要試圖設置多個…

代碼:

復制代碼
代碼如下:
<!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>www.52CSS.com</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 的屬性取出來,賦給 className。
  2、對于 expression,這里使用一個無關緊要的屬性(此處是zoom)來觸發,處理完需要做的事情之后,再將此屬性覆蓋掉以解決 expression 不斷執行的效率問題。
  代碼:

復制代碼
代碼如下:
<!--[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>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 长沙县| 辉县市| 依兰县| 白河县| 晋江市| 安泽县| 天镇县| 商丘市| 台北市| 赞皇县| 开原市| 乌兰察布市| 黑河市| 太保市| 建阳市| 凤翔县| 芦溪县| 苏尼特左旗| 武鸣县| 阜阳市| 德格县| 牙克石市| 雷波县| 噶尔县| 突泉县| 兰坪| 时尚| 大宁县| 杭锦旗| 正蓝旗| 托里县| 嘉峪关市| 和政县| 赣州市| 遵义市| 密山市| 闵行区| 辽源市| 丹阳市| 蒙城县| 顺昌县|