[黑马程序员]css选择器总结

---------------------- Windows Phone 7手机开发.Net培训、期待与您交流! ----------------------

1.对于非元素内联的样式需要定义样式选择器,通俗的话就是这个样式适合于哪些元素,有三种:标签选择器、class选择器和id选择器。
2.标签选择器,input{border-color:red;color:green;},是对于指定的标签采用统一的样式。
3.class选择器,以定义一个命名的样式,然后在用到它的时候设定元素的class属性为样式的名称,还可同时设定多个class,名称之间加空格,样式名称开头加‘.’,举个例子:
 .warning{background-color:Red;}
 .highlight{font-size:xx-large;cursor:help;}
 ---------------------------------------------------
 <div class="warning">hello</div>
     <div class="highlight">world</div>
     <div class="highlight warning">boys</div>
4.class选择器可以和标签选择器结合来使用 
 <style type="text/css">
        .warning{background-color:Red;}
     .highlight{font-size:xx-large;cursor:help;}
    
     input.accountno{text-align:right;color:Green}
     label.accountno{font-style:italic;}
     </style>
 ------------------------------------------------------
 <input class="accountno" type="text" value="123456" />
     <label class="accountno" >123456</label>
5.id选择器,是为指定的id设定样式,id前加#
 <style type="text/css">
            .warning{background-color:Red;}
     .highlight{font-size:xx-large;cursor:help;}
    
     input.accountno{text-align:right;color:Green}
     label.accountno{font-style:italic;}
    
     #username
     {
         font-size:xx-large;   
     }
     </style>
 ----------------------------------------------------
 <input id="username" type="text" value="wwwwww" />
6.以上三种可以结合使用
 <input id="username" type="text" class="accountno" style="display:block" value="kkkkk"/>
7.其他选择器
  7-1 关联选择器
 p strong{background-color:Yellow;}
 -------------------------------------------------
 <p><strong>ljfjljs</strong></p>
  7-2 组合选择器
 h1,h2,input{background-color:Purple;}
 -------------------------------------------------
 <h1>hello</h1>
     <input type="text" value="lljlskk"/>
  7-3 伪选择器,为标签的不同状态设定不同的样式
 A:visited超链接点击过的样式,A:active选中超链接的样式,A:link超链接未被访问的状态, A:hover鼠标移到超链接时的状态。
 A:visited{TEXT-DECORATION:none}
     A:active{TEXT-DECORATION:none}
     A:link{TEXT-DECORATION:none}
     A:hover{TEXT-DECORATION:underline}

---------------------- Windows Phone 7手机开发.Net培训、期待与您交流! ----------------------

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值