設定input type為text的文字框樣式
CSS 設定 input type="text" 標籤的樣式,而不會影響到 type="checkbox" 或其它input
第一種解決辦法:使用 JS 迴圈控制每個 type="text" 的文字框
<head runat="server">
<title>無標題頁</title>
<style type="text/css">
.myinput
{
border: red 1px solid;
font-size: 12px;
color:#000000;
}
</style>
<script type="text/javascript" language="javascript" defer>
var u=document.getElementsByTagName("input");
for(var i=0;i<u.length;i++){
if(u[i].type=="text")
u[i].className="myinput";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<input type="password" />
<input type="text" name="username"/><br>
<input type="checkbox" name="senior" value="全站"/>
</form>
</body>
如果還需要設定 password 的樣式,可以修改 if(u[i].type=="text") 為 if(u[i].type=="text" || u[i].type=="password") 這種用JS控制的方法比較複雜,實現程式碼也比較多。
第二種方法:
<style>
input {
border: expression(this.type=="text"?"1px solid #04576f":"");
}
</style>
<form>
<input type="text" name="username"/>
<br>
<input type="checkbox" name="senior" value="全站"/>
</form>
註明:如果放在aspx頁面中的話,必須去掉<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
expression才起作用了
相關文章
- 單獨設定input text文字框樣式
- css設定type為text的input元素的樣式CSS
- CSS 設定input文字框樣式CSS
- css設定input文字框樣式CSS
- css設定具有指定type屬性值的input文字框的樣式CSS
- CSS input文字框樣式CSS
- CSS input 文字框樣式CSS
- 為input文字框設定背景圖片
- 純css設定input文字框獲取焦點時的樣式CSS
- CSS匹配input text文字框CSS
- JavaScript獲取input text文字框JavaScript
- JavaScript設定input文字框只讀JavaScript
- 設定input文字框只讀效果
- input框type=file設定cursor:pointer的問題
- HTML中設定input等文字框為不可操作HTML
- javascript動態設定input文字框的值JavaScript
- 文字框獲取焦點設定樣式
- JavaScript 動態設定input文字框只讀JavaScript
- 獲得焦點時候設定文字框的樣式
- css匹配type屬性值為text的input元素CSS
- 給<input type="file">增加樣式
- HTML中input type="text"和type="password" 顯示的長度不一樣HTML
- js動態設定input文字框的readonly屬性JS
- JQuery設定文字框和密碼框獲得焦點時樣式jQuery密碼
- 設定文字框得到焦點或者失去焦點時的樣式
- CSS 設定文字樣式CSS
- javascript文字框獲取焦點設定其樣式程式碼JavaScript
- input[type="radio"]自定義樣式
- CSS實現的文字框獲取焦點設定樣式程式碼CSS
- input標籤單行文字域type="text"的可以新增屬性以及其描述
- CSS設定半個文字的樣式CSS
- css 文字框focus獲取焦點設定樣式程式碼例項CSS
- CSS 設定placeholder文字樣式CSS
- HTML input text單行文字域HTML
- jQuery不能修改input輸入框typejQuery
- input 文字框內容居中
- input只能輸入文字框
- 如何使用CSS設定文字框的邊框CSS