蓝森林首页 | 返回主页 | 本站地图 | 站内搜索 | 联系信箱 |
 您目前的位置:首页 > 自由软件 > 技术交流 > 应用编程


    

蓝森林 http://www.lslnet.com 2006年8月25日 8:28

[请教] 在CSS中,如何定义多个 Input 的属性

如题,大家知道,在CSS中可以为 input 定义样式:

input {
margin: 1px;
padding: 1px;
height: 19px;
font-size: 12px;
background-color: #FeFeFe;
      }

但是如果这样定义,那么 type="text" /type="checkbox" / type="submit"  这些类型的元素就统一为上面那一种样式风格,试问有没有一种办法,能够不使用class or id这样分别定义类,而使页面中的input元素按照type划分,分别有自己的样式?请指教!谢谢!论坛的历史帖子我搜索过相关的问题,虽然有人提出过,但始终没有得到解答,还望斑竹和版子里面的朋友们能够关心一下这个问题。期待ing...

同一页面采用两种input:
[html]

<Script Language="JavaScript">
     function borderColor(){
        if(self['oText'].style.borderColor=='red'){
           self['oText'].style.borderColor = 'yellow';
        }else{
           self['oText'].style.borderColor = 'red';
        }
        oTime = setTimeout('borderColor()',400);
     }
</Script>
<center>
<input type="text" id="oText" style="border:5px dotted red;color:red" onfocus="borderColor(this);" onblur="clearTimeout

(oTime);">









<br><br><br>

<style type=text/css>
.input{border-Width:'1px';border-Color:'black';width:'106';height:'21';zhenhong:expression(onmouseover=function()

{this.style.borderColor='black';this.style.backgroundColor='plum';},onmouseout=function()

{this.style.borderColor='black';style.backgroundColor='white';})};
</style>
<center>

<INPUT value="Type here" NAME="user_pass" TYPE="text"  class="input">

[/html]

谢谢 Marvellous ,但是这不是我所需要的答案,你在input的属性标签里面还是用了id="oText" style=""
我的意思是:
<input type="text">
<input type="checkbox">
<input type="submit">
这三个元素分别有自己的样式,区别于css中定义的 input{*****},不用在input标签属性中加入 class=**  或者 ID=**
:)

在CSS里定义
input[text]{....}
input[checkbox]{.....}
等等,,,就是这样
看看CSS指南。。上面有这样说过的。。。

input[text]
input[checkbox]

???
这样也能定义input标签么??
测试了也没弄出来,反而什么样式都没了
=============下面是小雨的手册中提到的相关内容:=========
Attribute Selectors    属性选择符


语法:

1. E1[attr]
2. E1[attr=value]
3. E1[attr~=value]
4. E1[attr|=value]

说明:

1. 选择具有attr属性的E1
2. 选择具有attr属性且属性值等于value的E1
3. 选择具有attr属性且属性值为一用空格分隔的字词列表,其中一个等于value的E1。这里的value不能包含空格
4. 选择具有attr属性且属性值为一用连字符分隔的字词列表,由value开始的E1
目前IE5.5+尚不支持此种选择符。

示例:

h[title] { color: blue; }
/* 所有具有title属性的h对象 */

span[class=demo] { color: red; }

div[speed="fast"][dorun="no"] { color: red; }

a[rel~="copyright"] { color:black; }

我是这么定义两个input的:
input[type=text]
    {
        background-color: #2E4972;
        }
input[type=submit]
    {
        background-color: #000000;
        }

可还是不行:(

[html]


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<style type="text/css">
<!--
input[type=text]
    {
        background-color: #2E4972;
        }
input[type=submit]
    {
        background-color: #000000;
        }
-->
</style>
</head>

<body>
<input type="text" name="textfield">
<input type="submit" name="Submit" value="提交">

</body>
</html>
[/html]

IE6 没作用

ft,这可怎么整?

Help~~~~

自己顶一下




Copyright © 1999-2000 LSLNET.COM. All rights reserved. 蓝森林网站 版权所有。 E-mail : webmaster@lslnet.com