带选择器的样式定义(一)

来源:互联网 发布:js 选项卡 编辑:程序博客网 时间:2024/06/05 14:30

css中定义样式时也是可以分类别的,比如说input元素中,只定义type=button的样式

<style type="text/css">input[type='button']{width:100px; height:100px;border:1px solid red;}</style><input type="button" value="click me" /><input type="text" />

上述中只要按钮的样式定义成宽高100px,边框红色。

这种css定义就是根据属性起个过滤的作用。

比如说下述代码:

<style type="text/css">.input[he='hi']{width:50px;width:50px;border:1px solid yellow;}</style><input type="text" he="hi" /><input type="text" /></style>

就是给属性he='hi'的input元素定义样式。

原创粉丝点击