Home  >  Article  >  Web Front-end  >  css设置具有指定type属性值的input文本框的样式_html/css_WEB-ITnose

css设置具有指定type属性值的input文本框的样式_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:28:521720browse

css设置具有指定type属性值的input文本框的样式:
如果想设置一个的样式,我们不能够擦用如下方式:

input{}

上面的方式可以设置所有的input元素的样式,不单单是文本框,当然我们可以找到其他的解决方案,在文本框上使用class属性或者style属性进行设置,但是这种方式还是比较麻烦,下面就通过css的属性选择器来实现此功能。
代码如下:

<!DOCTYPE html><html><head><meta charset=" utf-8"><meta name="author" content="http://www.softwhy.com/" /><title>蚂蚁部落</title><style type="text/css">input[type=text]{  width:200px;  height:30px;}</style></head> <body> <input type="text"/><input type="password"/></body> </html>

上面的代码利用属性选择器可以设置文本框的长度和高度。
属性选择器可以参阅CSS的属性选择符E[att="val"]一章节。

原文地址是:http://www.softwhy.com/forum.php?mod=viewthread&tid=15073

更多内容可以参阅:http://www.softwhy.com/divcss/

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn