通配样式的时候不要随意添加属性
例如我想美化输入框的效果:
<input type="text" name="textfield" />
避免给这样的通配属性:
input{background:#222; border:1px solid #4a4a49; color:#ccc; padding:1px 3px; }
否则所有的输入框、按钮、单选框、复选框都会跟着变化。
给通配属性容易,再删通配属性,恢复input的默认值就麻烦了。
如果你不幸,也犯了这种错误,考虑一下批量替换的方法来解决:
首先将
input{background:#222; border:1px solid #4a4a49; color:#ccc; padding:1px 3px; }变更为
.input-beauty{background:#222; border:1px solid #4a4a49; color:#ccc; padding:1px 3px; }
然后批量替换
type="text" 变更为 type="text" class="input-beauty"type="password" 变更为 type="password" class="input-beauty"这样哪个输入框需要美化,就调用样式,不需要就不调用。
由此,更加渴望CSS3的早日普及,将来直接用input[type="text"]这种玩意来实现。

12/28/2009 at 12:09
有IE6在就算出了CSS5也没用啊。。。
还是得怎么麻烦怎么来。。
回复
12/28/2009 at 15:22
除非万恶的IE6消灭了,不然还是要考虑这个老古董的。
最近做到项目就需是用input[type="text"]来操作的,直接无视IE6。
回复
01/22/2010 at 16:59
由于ie6的存在。。。个人还是会这样做的:
…
回复