CSS3----目标伪类选择器

效果:

代码:

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>目标伪类选择器</title>
    <style type="text/css">
    .container {
        background-color: #fff;
        color: #424242;
        font: 12px Arial, Verdana, sans-serif;
        margin: 0 auto;
        padding: 10px;
        width: 500px;
    }

    .container h2 {
        margin: 5px 0;
        padding: 0;
        position: relative;
    }

    .container h2:before {
        border: 5px solid #fff;
        border-color: #fff transparent transparent;
        content: "";
        height: 0;
        position: absolute;
        right: 10px;
        top: 15px;
        width: 0;
    }

    .container h2 a {
        color: red;
        background: #8f8f8f;
        background: -moz-linear-gradient(top, #cecece, #8f8f8f);
        background: -webkit-gradient(linear, left top, left bottom, from(#cecece), to(#8f8f8f));
        background: -o-linear-gradient(top, #cecece, #8f8f8f);
        background: linear-gradient(top, #cecece, #8f8f8f);
        border-radius: 5px;
        color: #424242;
        display: block;
        font-size: 13px;
        font-weight: normal;
        padding: 10px;
        text-shadow: 2px 2px 2px #aeaeae;
        text-decoration: none;
    }

    :target h2 a,
    .container h2 a:focus,
    .container h2 a:hover,
    .container h2 a:active {
        background: #2288dd;
        background: -moz-linear-gradient(top, #6bb2ff, #2288dd);
        background: -webkit-gradient(linear, left top, left bottom, from(#6bb2ff), to(#2288dd));
        background: -webkit-linear-gradient(top, #6bb2ff, #2288dd);
        background: -o-linear-gradient(top, #6bb2ff, #2288dd);
        background: linear-gradient(top, #cecece, #2288dd);
        color: #fff;
    }

    .container p {
        margin: 0;
        height: 0;
        overflow: hidden;
        padding: 0 10px;
        -moz-transition: height 0.5s ease-in;
        -webkit-transition: height 0.5s ease-in;
        -o-transition: height 0.5s ease-in;
        transition: height 0.5s ease-in;
    }

    :target p {
        height: 100px;
        overflow: auto;
    }

    :target h2:before {
        border-color: transparent transparent transparent #fff;
    }
    </style>
</head>

<body>
    <div class=‘container‘>
        <div class="mune-list" id="brand">
            <h2><a href="#brand">Brand</a></h2>
            <p>Sunlike阿理旺旺1</p>
        </div>
        <div class="mune-list" id="promotion">
            <h2><a href="#promotion">Promotion</a></h2>
            <p>Sunlike阿理旺旺2</p>
        </div>
        <div class="mune-list" id="event">
            <h2><a href="#event">Event</a></h2>
            <p>Sunlike阿理旺旺3</p>
        </div>
    </div>
</body>

</html>

  

  

 

时间: 2025-01-18 01:37:06

CSS3----目标伪类选择器的相关文章

CSS3 结构性伪类选择器(2)

CSS3 结构性伪类选择器-first-child ":first-child"选择器表示的是选择父元素的第一个子元素的元素E.简单点理解就是选择元素中的第一个子元素,记住是子元素,而不是后代元素. 示例演示 通过":first-child"选择器定位列表中的第一个列表项,并将序列号颜色变为红色. HTML代码: <ol> <li><a href="##">Link1</a></li>

Atitit.隔行换色 &#160;变色 css3 结构性伪类选择器

Atitit.隔行换色  变色 css3 结构性伪类选择器 1.1. css3隔行换色扩展阅读 1 1.2. 结构伪选择器 1 1.3. jQuery 选择器2 1.1. css3隔行换色扩展阅读 原理就是利用结构伪类选择器 .list_div tr:nth-of-type(odd){background:#fff;} /* 奇数行 */ /*-------------------------------*/ .list_div tr:nth-of-type(even){ background:

CSS3 结构伪类选择器 详解

1 CSS3 结构伪类选择器 1.E:root 匹配E元素所在的根元素 即:html 2. E:nth-child(n) (1)匹配E元素的父元素中第n个子元素,(2)且该位置的子元素类型必须是E类型.否则无效 p:nth-child(1){color:red} <div> <p>这是红色的<p> </div> <div> <h1>这是第一个子元素 但不是P类型,不是红色</h1> < p>这是黑色的 注意对比

css3中伪类选择器和伪元素介绍

利用html5和css3开发出炫酷的网页,那么对于一个web前端开发者,css3也是必须要掌握的,下面和大家讨论一下css3中伪类选择器和伪元素. 类选择器 在css中可以使用类选择器把相同的元素定义成不同的样式.比如:p.left{text-align: left}p.rigth{text-align: right} 伪类选择器 类选择器和伪类选择器的区别在于,类选择器我们可以随意起名,而伪类选择器是CSS中已经定义好的选择器,不可以随意起名. 最常见的伪类选择器 a:link{ color:

CSS3 nth 伪类选择器

考察下面的 HTML 代码片段: <div> <section>section 1</section> <section>section 2</section> <ul> <li>item 1</li> <li> <ul> <li>sub item 1</li> <li>sub item 2</li> <li>sub item

CSS3:nth-child()伪类选择器,Table表格奇偶数行定义样式

转自爱设计 原文链接http://www.dangshopex.com/jishufenxiang/WEBkaifajishu/8653.html CSS3的强大,让人惊叹,人们在惊喜之余,又不得不为其艰难的道路感到可惜:好的标准只有得到行业浏览器的良好支持才算得上“标准”.CSS3标 准已提出数年,但是目前能实现她的浏览器并不多,虽然部分浏览器能实现部分规范,但这又有什么用呢?面对更多的兼容性问题,CSSer们只有望洋轻叹.虽 然如此,但有前瞻性的我们,又怎能停步不前呢?今天我们就来“前瞻”一

CSS3:nth-child()伪类选择器

Table表格奇偶数行定义样式: CSS3的强大,让人惊叹,人们在惊喜之余,又不得不为其艰难的道路感到可惜:好的标准只有得到行业浏览器的良好支持才算得上“标准”.CSS3标 准已提出数年,但是目前能实现她的浏览器并不多,虽然部分浏览器能实现部分规范,但这又有什么用呢?面对更多的兼容性问题,CSSer们只有望洋轻叹.虽 然如此,但有前瞻性的我们,又怎能停步不前呢?今天我们就来“前瞻”一下CSS3的一个伪类选择器“:nth-child()”. 语法: :nth-child(an+b) 为什么选择她,

:nth-child(css3的伪类选择器)

伪类选择器,表示匹配其下的子元素 :nth-child(n)    表示从第n个子元素,「n」代表的是由0起始的遞增數字 :nth-child(an=b)   「n」代表的是由0起始的遞增數字,「a」與「b」則是你可以自訂的一個數值,且兩者數值可以不同 :nth-child(3n+10)表示从第10个开始,10,13,16,19……:nth-child(3n)则Y=0,可省略,表示从0开始,0,3,6,9……

css3基础 :target 目标伪类选择器 简单示例

礼悟:    公恒学思合行悟,尊师重道存感恩.叶见寻根三返一,江河湖海同一体.          虚怀若谷良心主,愿行无悔给最苦.读书锻炼养身心,诚劝且行且珍惜.              ide:visual studio 2017             browser:Chrome                     os:win7 学习链接: http://blog.csdn.net/atleks/article/details/38966691 代码 <!DOCTYPE html>

css3结构伪类选择器first-child,last-child,nth-child(),nth-last-child()

1  element:first-child 选择属于其父元素的首个子元素的element元素 注意:div:first-child 必须是其父元素下面的第一个子元素且必须是div元素才能匹配的到 匹配结果: 2  同理:element:last-child 指定其父元素的最后一个子元素的element元素 注意:div:last-child  代表其父元素的最后一个元素一定是div才能匹配到 3    :nth-child(n) 选择器匹配属于其父元素的第N个子元素 匹配结果 4, :nth-