关于样式的问题
如果有一个输入框和一个按钮,他们的样式不一样,但是又不能独立使用样式(他们被封装在一起了)。我是否可以使用类似input.text input.button 等来设置他们的样式呢?具体格式是?
...全文
请发表友善的回复…
发表回复
LoveTide 2003-11-10
- 打赏
- 举报
CSS 2.0 的 Selector:
input[type="text"] {.....}
input[type="button"] {.....}
遗憾的是 IE(IE6) 不支持,而Netscape6.1以上却支持。。。
实在不行,就只有写一段 JavaScript 代码了。。。
var i = 0;
var allInputElements = document.getElementsByTagName ("INPUT");
for (i=0; i<allInputElements.length; i++)
{
if (allInputElements[i].type.toLowerCase()=="text")
allInputElements[i].class="自定义的Text样式class";
else if (allInputElements[i].type.toLowerCase()=="button")
allInputElements[i].class="自定义的button样式class";
}
input[type="text"] {.....}
input[type="button"] {.....}
遗憾的是 IE(IE6) 不支持,而Netscape6.1以上却支持。。。
实在不行,就只有写一段 JavaScript 代码了。。。
var i = 0;
var allInputElements = document.getElementsByTagName ("INPUT");
for (i=0; i<allInputElements.length; i++)
{
if (allInputElements[i].type.toLowerCase()=="text")
allInputElements[i].class="自定义的Text样式class";
else if (allInputElements[i].type.toLowerCase()=="button")
allInputElements[i].class="自定义的button样式class";
}
kathy_78 2003-11-10
- 打赏
- 举报
funboy88(司令) 不能用这种办法啊,因为text和button不能分别设置成两种样式,他们被封装在一个不可以修改的控件里面。
只能指定全页面的text用一种样式,而全部button用另外一种样式。问题时又没有一种方法可以指定?以前好像见过想不起来了。
只能指定全页面的text用一种样式,而全部button用另外一种样式。问题时又没有一种方法可以指定?以前好像见过想不起来了。
funboy88 2003-11-10
- 打赏
- 举报
<head>
<style type="text/css">
inputText {width:30px;height:30px;.......};
inputButton {width:40px;height:40px;.......};
</style>
</head>
<input type=text class=inputText>
<input type=button class=inputButton>
<style type="text/css">
inputText {width:30px;height:30px;.......};
inputButton {width:40px;height:40px;.......};
</style>
</head>
<input type=text class=inputText>
<input type=button class=inputButton>
freetaiger 2003-11-10
- 打赏
- 举报
<head>
<style type="text/css">
input {width:30px;height:30px;.......}
</style>
</head>
<style type="text/css">
input {width:30px;height:30px;.......}
</style>
</head>