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

首頁 > 開發 > CSS > 正文

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

2024-07-11 08:22:12
字體:
來源:轉載
供稿:網友
  用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>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 家居| 衡东县| 青田县| 兰考县| 新竹市| 塔城市| 寿光市| 和田县| 车致| 金堂县| 富川| 灌南县| 长海县| 宁海县| 兴山县| 邵阳县| 临沂市| 清水县| 淮北市| 巩留县| 黑龙江省| 舞钢市| 南江县| 平谷区| 松阳县| 新昌县| 湖州市| 穆棱市| 顺义区| 平塘县| 昌宁县| 大邑县| 铜山县| 肥乡县| 当雄县| 浦城县| 陆良县| 屏东县| 屯门区| 龙胜| 信宜市|