CSS Web page Production example: Conditional add hover style

Source: Internet
Author: User
Tags add

Article Introduction: CSS Web page Production instance: Conditional add hover style.

To add a hover style to the element, it's simple, let's look at an example of transparency:

1
2
3
4
5
6
div {
opacity:
					1.0;
}
Div:hover {
opacity:
					0.5;
}

But what if we just want to make the div display that's really hover, and let the other div blur?
Suppose our HTML structure is as follows:

1
2
3
4
5
<section>
<div></div>
<div></div>
<div></div>
</section>

We can add the following opacity attributes to all DIV elements:

1
2
3
. parent:hover > Div {
opacity:
					0.5;
}

And then we'll deal with that really hover div:

1
2
3
. parent:hover > Div:hover {
opacity:
					1.0;
}

Who's using it?
A sensitive push in their for Mac program using the relevant technology, the effect is good:

Instance

This idea can be extended to a number of places, here is a list of examples, when you mouse into the list, the remaining columns of transparency, the same in this column, but the transparency has layers of increase, visual effect is very good. The code is like this:

1
2
3
4
5
6 7 8 9 (15) An-i-am
)
29
<div id= "All" > <ul> <li><a href= "#" >---</a></li> <li><a href= "#" >--- </a></li> <li><a href= "#" >---</a></li> <li><a href= "#" >---</a ></li> <li><a href= "#" >---</a></li> <li><a href= "#" >---</a>< /li> <li><a href= "#" >---</a></li> </ul> <ul> <li><a href= "#" >--- </a></li> <li><a href= "#" >---</a></li> <li><a href= "#" >---</a ></li> <li><a href= "#" >---</a></li> <li><a href= "#" >---</a><
/li> <li><a href= "#" >---</a></li> <li><a href= "#" >---</a></li> </ul> <ul> <li><a href= "#" >---</a></li> <li><a href= "#" >---</a ></li> <li><a href= "#" >---</a></li>; Li><a href= "#" >---</a></li> <li><a href= "#" >---</a></li> <li> <a href= "#" >---</a></li> <li><a href= "#" >---</a></li> </ul> </ Div>

CSS style:

1
2
3
4
5
6
7 8 9 (
28) (a)
					#all > ul {list-style:none;
					Float:left;
                width:200px;
            padding:0 10px 0 0;
                        } #all a {text-decoration:none;
                        Display:block;
                        padding:10px;
                        Background: #900;
                        border-radius:20px;
                        Color:white;
                        Text-align:center; 
margin:0 0 5px 0;
                         -webkit-transition:all 0.2s ease;
                        -moz-transition:all 0.2s Ease;
            -o-transition:all 0.2s Ease;
            #all: hover a {opacity:0.2;
            #all: Hover ul:hover a {opacity:0.5; } #all: Hover uL:hover a:hover {opacity:1; }

Click here to view demo

Attention

This little trick, the old-fashioned browser is not supported, because they only have a label on the hover characteristics, if you want to achieve the corresponding effect, then you need to use JS to detect the mouse into the event. [中文版]

Reprint Please specify:
Author: rockux–web Front end
From: Conditional add hover style



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.