在网页上,你会看到很多美丽的悬停效果,尤其是用于作品集页面时,当你悬停在一个项目上时,其他项目将会变得不透明,因此你所悬停的项目将会被突出显示。
我尝试实现了这个效果,并且完成了这个代码(还有一个更详细的版本在CodePen中):
a {
text-decoration: none;
transition: color 0.1s linear;
-moz-transition: color 0.1s linear;
-webkit-transition: color 0.1s linear;
-o-transition: color 0.1s linear;
}
a:link, a:visited { color: inherit; } /* Body color */
a:hover, a:active { color: #d7354a; }
h1, h2, h3, h4, h5, h6 { font-weight: normal; /*margin: 16px 0;*/ }
h1 {
font-family: "Adelle", Arial, sans-serif;
font-size: 80px;
line-height: 90px;
}
h3, h4 { color: #000; }
h3 {
font-size: 28px; /* 28px / 16px = 100% */
font-weight: 600;
line-height: 38px;
}
.txt-center { text-align: center; }
body {
margin: auto;
font-family: "Merriweather", Arial, sans-serif;
font-size: 18px; /* 18px = 100% */
line-height: 26px;
letter-spacing: 1px;
color: #6f6f6f;
-webkit-font-smoothing: none;
-webkit-font-smoothing: subpixel-antialiased;
-webkit-font-smoothing: antialiased;
}
section {
padding: 80px 0;
position: relative;
}
#register div:hover .group { opacity: .5; }
#register div .group:hover { opacity: 1; }
#register hgroup { margin-bottom: 80px; }
#register .group a {
display: block;
color: #333;
}
#register .group a:hover .button {
background: #FFF;
color: #d7354a;
-webkit-transition: all 0.2s ease;
-moz-transition: all 0.2s ease;
-ms-transition: all 0.2s ease;
-o-transition: all 0.2s ease;
transition: all 0.2s ease;
}
#register .group figure { margin-bottom: 30px; }
#register .group figure img {
display: inline-block;
vertical-align: middle;
-webkit-transform: translateZ(0);
-moz-transform: translateZ(0);
-o-transform: translateZ(0);
transform: translateZ(0);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-webkit-transition-duration: 0.3s;
-moz-transition-duration: 0.3s;
-o-transition-duration: 0.3s;
transition-duration: 0.3s;
-webkit-transition-property: transform;
-moz-transition-property: transform;
-o-transition-property: transform;
transition-property: transform;
-webkit-transition-timing-function: ease-out;
-moz-transition-timing-function: ease-out;
-o-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
#register .group:hover figure img {
-webkit-transform: translateY(-6px);
transform: translateY(-6px);
}
#register .group p:first-of-type {
font-family: "Ubuntu", Arial, sans-serif;
font-size: 22px;
font-weight: 500;
}
#register .group h3 {
font-size: 70px;
line-height: 100px;
font-weight: 400;
color: inherit;
text-transform: lowercase;
}
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<main class="main">
<section class="page-header" id="register">
<div class="container">
<div class="row">
<hgroup class="col-md-10 col-md-offset-1 txt-center">
<h1>
Register
</h1>
</hgroup><!-- End hgroup.col-md-10 col-md-offset-1 -->
<div class="col-md-6 group txt-center">
<a href="#">
<figure>
<img src="http://placehold.it/120x120" alt="Register as Watcher">
</figure>
<p>Register as</p>
<h3>Watcher</h3>
<p>
Suspendisse sodales ut neque ut facilisis. <br>
Cras lobortis vestibulum varius.
</p>
<div class="button secondary">I am a watcher</div>
</a>
</div><!-- End div.col-md-6 group txt-center -->
<div class="col-md-6 group txt-center">
<a href="#">
<figure>
<img src="http://placehold.it/120x120" alt="Register as Vlogger">
</figure>
<p>Register as</p>
<h3>Vlogger</h3>
<p>
Suspendisse sodales ut neque ut facilisis. <br>
Cras lobortis vestibulum varius.
</p>
<div class="button secondary">I am a vlogger</div>
</a>
</div><!-- End div.col-md-6 group txt-center -->
</div><!-- End div.row -->
</div><!-- End div.container -->
</section><!-- End section#hero -->
</main>
上时,它会使另一个项目的不透明度降低。
我知道您可以使用jQuery实现此目的,但我也知道这应该可以仅使用CSS实现。我该如何实现我所寻找的内容?
我知道您可以使用jQuery实现此目的,但我也知道这应该可以仅使用CSS实现。我该如何实现我所寻找的内容?