CSS-扩展选择器

5 篇文章 0 订阅

扩展选择器

    1、关联选择器

        <div><p>aaaaaaa</p></div>

        设置div标签里面的p标签的样式,嵌套标签里面的样式

         div p
{
background-color:red;

}

<!doctype html>
<html>
 <head>
  <title>Document</title>
  <style type = "text/css">
  	div p
	{
	background-color:red;
	}
  </style>
 </head>
 <body>
	<div><p>中国社会主义牛逼</p></div>
	<p>wwwwwwwwww</p>
 </body>
</html>

 

    2、组合选择器

 

        <div>111</div>

        <p>2222</p>

        把div和p标签设置成相同的样式

         div,p
{
background-color:red;

}

<!doctype html>
<html>
 <head>
  <title>Document</title>
  <style type = "text/css">
  	div,p
	{
		background-color:red;
	}
  </style>
 </head>
 <body>
	<div>11111111</div>
	<p>222222222</p>
 </body>
</html>

    3、伪元素选择器

        css里面提供了一些定义好的样式,可以直接使用

        比如使用超链接

            超链接的状态:

                原始状态,鼠标放上去的状态,点击时的状态,点击后的状态

                :link           :hover                   :active              :visited

<!doctype html>
<html>
 <head>
  <title>Document</title>
  <style type = "text/css">
  /* 原始状态 */
  	a:link
	{
		background-color:red;
	}
	/* 悬停状态*/
	a:hover
	{
		background-color:green;
	}
	/*点击时状态*/
	a:active
	{
		background-color:blue;
	}
	/*点击后的状态*/
	a:visited
	{
		background-color:gray;
	}
  </style>
 </head>
 <body>
  <a href = "http://www.baidu.com.cn" target = "_blank">超链接测试111</a>
  
 </body>
</html>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值