input的css定义技巧
input竟然可以创造出10个不同的东西:
<input type="text" /> 文本框
<input type="password" /> 密码框
<input type="submit" /> 提交按钮
<input type="reset" /> 重置按钮
<input type="radio" /> 单选框
<input type="checkbox" /> 复选框
<input type="button" /> 普通按钮
<input type="file" /> 文件选择控件
<input type="hidden" /> 隐藏框
<input type="image" /> 图片按钮
input真是一个伟大的东西,但是当你真正在项目中试图给不同的控件设置不同的样式时,你就会发现input真的可以把“你的头搞大”。我不知道为什么当初要给input赋予那么多身份,但是,他的“N重身份”给网站设计者的确带来了不少的麻烦。解决问题的办法还是有,但是都有各自致命的缺点 Orz…大致归纳一下:
1.用css的expression判断表达式
2.用css中的type选择器
3.用javascript脚本实现
4.如果你用Microsoft Visual Studio 2005 或者后续版本开发项目,恭喜,你还可以使用skin。
下面就来讲解一下各个办法的详细实现和它们的优缺点。
1:用css的expression判断表达式
实现代码参考:
<!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN" "doc.guandang.net;
<html xmlns="doc.guandang.net; >
<head>
<title> diffInput2 </title>
<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':'#000');
}
</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>
优点:简单,轻量级
缺点:expression判断表达式FireFox是不支持的。致命的是只能区分出一个(例如例子中就只能区分出text文本框),不要试图设置多个,下面的会将上面的覆盖掉 Orz…
2:用css中的type选择器
实现参考代码:
<!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN" "doc.guandang.net;
<html xmlns="doc.guandang.net; >
<head>
<title> diffInput2 </title>
<meta name="Keywords" content=""/>
<meta name="Description" content=""/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
input[type="text"]
{
background-color:#FFC;
}
input[type="password"]
{
background-image:url(BG.gif);
}
input[type="submit"]
{
background-color:blue;
color:white;
}
input[type="reset"
CSS 小技巧 一,input 背景延伸当 input 有背景,并且输入字数不限制的时候,字符...十二,CSS 定义通用透明效果分别定义各种浏览器的透明效果: .transparent{ filter...
<style type="text/css"> <!-input { width:200px; height:30px; ...定义 1px 左右高度的容器 IE6 下这个问题是因为默认的行高造成的,解决的技巧...
<style type="text/css"><!-- input { width:200px; height:30px; ...首先在父级元素定义 text-algin: center; 这个的意思就是在父级元素内的内容...
CSS定义问题_IT/计算机_专业资料。CSS 样式表 CSS 样式表, 可以用于控制网页... input的css定义技巧 3页 免费 第八课 定义css样式 4页 免费 css整体样式...
{ margin:0 auto;width:982px; position:relative;background:#FFF;} input,...{zoom:1} 每一个用css控制的网站,都需要有一个默认的全局定义的css样式,今天...
-input { width:200px; height:30px; border:1px solid red; vertical-align...并使用前面定义的 css 的样式: <div id="item">some text here</div> 在...
/* 全局 CSS 定义 */ body { text-align: center; font-family:"宋体", ... <base> <br> <hr> <img> <input> <link> <meta> <nobr> 请问如何...
现一次。对一个标签同时使用 class 和 id 进行 CSS 定义,如果定义有重复,id...Input type=“radio” vertical-align:text-bottom; margin-bottom:1px; 清除...
当 input 或 select 与其他标签(例如 a、label)混排时,可能出现不居中的问题... input的css定义技巧 3页 免费 CSS分类控制input标签样... 1页 1下载券 ...
.input 5.选择器的复合声明 在利用 CSS 选择器...新建名称为“.lead”的类样式,定义在样式表文件“...9. CSS 使用技巧 1)CSS 禁用/启用 CSS 禁用/...
热门文档