CSS underline animation not working at all [duplicate] - html

This question already has answers here:
How to animate underline from left to right?
(3 answers)
Closed 6 months ago.
I am trying to make an underline animation that comes from the middle and extends to the sides
I copied the code from an example i found online which was working but not on my case
I have added the code on jsfiddle below
you are looking in the beginning of the css for .htext:after and .htext:after:hover
https://jsfiddle.net/wvm2sfp0/1/
body {
background: rgb(14, 13, 13);
color: white;
width: 100%;
}
header {
width: 100%;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
background: linear-gradient(to top, rgba(0, 0, 0, 0), rgb(0, 0, 0, 0.8));
}
a {
text-decoration: none;
color: inherit;
}
p {
color: white;
}
.div1 {
background-image: url(../images/Group\ 10.png);
}
.htext {
margin-right: 3%;
font-size: 0.75vw;
transition: text-decoration 0.3s;
}
.htext:after {
content: '';
position: absolute;
width: 100%;
transform: scaleX(0);
height: 2px;
bottom: 0;
left: 0;
background-color: #54B3A1;
transform-origin: center;
transition: transform 0.25s ease-out;
margin-bottom: -20px;
}
.htext:after:hover {
transform: scaleX(1);
transform-origin: center;
}
.logo1 {
margin-right: 10%;
height: 7%;
width: 8%;
}
.logo2 {
margin-right: 1.5%;
}
<div class="div1">
<header>
<img src="images/viennalogo.png" class="logo1">
<a href="#" class="htext">
<p>HOME</p>
</a>
<a href="#" class="htext">
<p>BRANDS WE WORK WITH</p>
</a>
<a href="#" class="htext">
<p>BRAND GALLERY</p>
</a>
<a href="#" class="htext">
<p>NEWS</p>
</a>
<a href="#" class="htext">
<p>ABOUT US</p>
</a>
<a href="#" class="htext">
<p>CONTACT</p>
</a>
<img src="images/Facebook.png">
<img src="images/Instagram.png">
<img src="images/Twitter.png">
</header>
</div>

well for an underline expansion, I wouldn't go with scaleX (for a lot of reasons)...
Instead, try this (I hope it's what you're looking for:
.htext {
margin-right: 3%;
font-size: 0.75vw;
transition: text-decoration 0.3s;
display: inline-block;
padding: 15px 20px;
position: relative;
}
.htext:after {
background: none repeat scroll 0 0 transparent;
bottom: 0;
content: "";
display: block;
height: 2px;
left: 50%;
position: absolute;
background: #54B3A1;
transition: width 0.3s ease 0s, left 0.3s ease 0s;
width: 0;
}
.htext:hover:after {
width: 100%;
left: 0;
}
For this to work, make sure your .htext class has a relative position, and that your .htext:after is absolute to that.

Related

Why the images in the background are glow up when I click?

When I click my <a> tag for the popup box, the images in the background (with overlay effects) are glowing up, and I don't know why. If anybody know something I write the code under here.
As you can see I've put href to #popup1 in the first <a> tag, and it opens the popup box, but in the background you can see the image like glowing, the border too.
I've changed the display tag and other CSS tags, but nothing.
Here is the Codepen.
the problem is actually you add pop-up before container 2 so that's why it is glowing.
So, if you dont want to make this glow just add your pop-up division after both
containers like this.
Dont change your Css. you just have to change position of divisions like this
<div class="container1" style="cursor:default;">
<div class="container2">
<div class="content">
<a id="ant" href="#popup1" onclick="show('popup2')">
<div class="content-overlay"></div>
<img class="content-image" src="https://i.postimg.cc/5tNkjkV5/2.png" style="z-index: 0;height: 200px;width: 330px;border:2px solid rgb(205,144,76);padding:0;">
<div class="content-details fadeIn-bottom" style="background-size:cover;">
<h3 class="content-title" style="font-family: 'Roboto', sans-serif;">ANTIPASTI</h3>
<p class="content-text"></p>
</div>
</a>
</div>
</div>
<div class="container2">
<div class="content">
<a id="prim">
<div class="content-overlay"></div>
<img class="content-image" src="https://i.postimg.cc/5tNkjkV5/2.png" style="border:2px solid rgb(205,144,76);padding:0; height:200px; width:330px;">
<div class="content-details fadeIn-bottom">
<h3 class="content-title" style="font-family: 'Roboto', sans-serif;"> PRIMI PIATTI </h3>
<p class="content-text"></p>
</div>
</a>
</div>
</div>
</div>
<div id="popup1" class="popup">
×
<h2>The Popup Has Arrived</h2>
<p>QUESTI SONO GLI ANTIPASTI</p>
</div>
<a href="#ant" class="close-popup"></a
It depends on the order of your HTML-Elements. This example will fix the problem
.container1 {
display: flex;
width: 100%;
flex-wrap: wrap;
margin-top: 110px;
align-content: space-around;
justify-content: center;
transition: all 0.2s linear;
}
.container1 > div {
padding: 40px;
justify-content: center;
}
*,
*:before,
*:after {
margin: 0;
padding: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.main-title {
color: #2d2d2d;
text-align: center;
text-transform: capitalize;
padding: 0.7em 0;
}
.container {
padding: 1em 0;
float: left;
width: 50%;
}
#media screen and (max-width: 640px) {
.container {
display: block;
width: 100%;
}
}
#media screen and (min-width: 900px) {
.container {
width: 33.33333%;
}
}
.container .title {
color: #1a1a1a;
font-family: 'Roboto', sans-serif;
text-align: center;
margin-bottom: 10px;
}
.content {
position: relative;
width: 100%;
max-width: 400px;
height: 100%;
margin: auto;
overflow: hidden;
transition: transform 0.4s;
}
.content .content-overlay {
/* background: rgba(70,34,0);*/
background: rgba(214, 142, 60, 70%);
/* background: rgb(214,142,60);*/
position: absolute;
height: 97%;
width: 100%;
left: 30px;
top: 0;
bottom: 0;
right: 0;
opacity: 0;
-webkit-transition: all 0.4s ease-in-out 0s;
-moz-transition: all 0.4s ease-in-out 0s;
transition: all 0.4s ease-in-out 0s;
}
.content:hover .content-overlay {
opacity: 0.5;
}
.content-details {
position: absolute;
text-align: center;
padding-left: 1em;
padding-right: 1em;
width: 100%;
top: 50%;
left: 50%;
opacity: 0;
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
-webkit-transition: all 0.3s ease-in-out 0s;
-moz-transition: all 0.3s ease-in-out 0s;
transition: all 0.3s ease-in-out 0s;
}
.content:hover .content-details {
top: 50%;
left: 50%;
right: 50%;
opacity: 1;
}
.content-details h3 {
color: #fff;
font-weight: 500;
text-align: center;
letter-spacing: 0.15em;
margin-bottom: 0.5em;
padding-left: 20px;
text-transform: uppercase;
}
.content-details p {
color: #fff;
font-size: 0.8em;
text-align: center;
padding-left: 20px;
}
.fadeIn-bottom {
top: 80%;
}
.fadeIn-top {
top: 20%;
}
.fadeIn-left {
left: 20%;
}
.fadeIn-right {
left: 80%;
}
h1 {
font-size: 3em;
text-align: center;
color: #00898e;
margin: 0;
padding: 30vh 0 1em;
}
h2 {
text-align: center;
white-space: nowrap;
color: #00898e;
}
a {
text-decoration: none;
color: #fff;
}
p {
text-align: left;
}
.btn {
display: inline-block;
padding: 10px 20px;
border: 2px solid #00898e;
border-radius: 10px;
transition: background 0.3s;
}
.btn:hover {
background: #00898e;
}
.popup {
position: fixed;
padding: 10px;
max-width: 500px;
border-radius: 10px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: rgba(255, 255, 255, 0.9);
visibility: hidden;
opacity: 0;
/* "delay" the visibility transition */
-webkit-transition: opacity 0.5s, visibility 0s linear 0.5s;
transition: opacity 0.5s, visibility 0s linear 0.5s;
z-index: 1;
}
.popup:target {
visibility: visible;
opacity: 1;
/* cancel visibility transition delay */
-webkit-transition-delay: 0s;
transition-delay: 0s;
}
.popup-close {
position: absolute;
padding: 10px;
max-width: 500px;
border-radius: 10px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: rgba(255, 255, 255, 0.9);
}
.popup .close {
position: absolute;
right: 5px;
top: 5px;
padding: 5px;
color: #000;
transition: color 0.3s;
font-size: 2em;
line-height: 0.6em;
font-weight: bold;
}
.popup .close:hover {
color: #00e5ee;
}
.close-popup {
background: rgba(0, 0, 0, 0.7);
cursor: default;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
opacity: 0;
visibility: hidden;
/* "delay" the visibility transition */
-webkit-transition: opacity 0.5s, visibility 0s linear 0.5s;
transition: opacity 0.5s, visibility 0s linear 0.5s;
}
.popup:target + .close-popup {
opacity: 1;
visibility: visible;
/* cancel visibility transition delay */
-webkit-transition-delay: 0s;
transition-delay: 0s;
}
<div class="container1" style="cursor: default">
<div class="container2">
<div class="content">
<a id="ant" href="#popup1" onclick="show('popup2')">
<div class="content-overlay"></div>
<img
class="content-image"
src="https://i.postimg.cc/5tNkjkV5/2.png"
style="z-index: 0; height: 200px; width: 330px; border: 2px solid rgb(205, 144, 76); padding: 0"
/>
<div class="content-details fadeIn-bottom" style="background-size: cover">
<h3 class="content-title" style="font-family: 'Roboto', sans-serif">ANTIPASTI</h3>
<p class="content-text"></p>
</div>
</a>
</div>
</div>
<div class="container2">
<div class="content">
<a id="prim">
<div class="content-overlay"></div>
<img
class="content-image"
src="https://i.postimg.cc/5tNkjkV5/2.png"
style="border: 2px solid rgb(205, 144, 76); padding: 0; height: 200px; width: 330px"
/>
<div class="content-details fadeIn-bottom">
<h3 class="content-title" style="font-family: 'Roboto', sans-serif">PRIMI PIATTI</h3>
<p class="content-text"></p>
</div>
</a>
</div>
</div>
<!-- The popup should be entered as the last element so that it overlays the other elements -->
<div id="popup1" class="popup">
×
<h2>The Popup Has Arrived</h2>
<p>QUESTI SONO GLI ANTIPASTI</p>
</div>
</div>

Animation when hovering over a button

I am trying to make some animated effect by adding a rectangle that expands over the button when the button (not the rectangle since it's set to width: 0px;) is hovered over by the user. Though, I don't really know how to do that, so I'm blocked.
So:
There's a button.
There's a rectangle somewhere.
The rectangle is 0px width.
I want the rectangle to grow from 0 to 200px width when the button is hovered. NOT the button.
I accept javascript solutions but only like real basic ones cause I'm a beginner, I won't understand javascript if it's not explained to me.
For the moment, here's my code:
HTML:
<div class="flex-container">
<div class="sidebar">
<button style="margin-top: 100px;" onclick="Accueil()"><div style="z-index: 2;">Accueil</div></button>
<div class="rectangle" name="acc" style="top: 100px;"></div>
<button onclick="Thés()"><div style="z-index: 2;">Thés</div></button>
<div class="rectangle" name="the" style="top: 100px;"></div>
<button onclick="Tisanes()"><div style="z-index: 2;">Tisanes</div></button>
<div class="rectangle" name="tis" style="top: 100px;"></div>
<button onclick="Théières()"><div style="z-index: 2;">Théières</div></button>
<div class="rectangle" name="thei" style="top: 100px;"></div>
</div>
CSS:
.sidebar > button {
margin: 20px; /* marge de 30px entre les boutons */
width: 200px;
height: 60px;
max-height: 60px !important;
max-width: 200px !important;
background-color: #F5FAD2;
text-align: center;
font-size: 24px;
border-radius: 7%;
border: none;
transition-duration: 0.4s;
cursor: pointer;
color: #404040;
position: relative;
}
.rectangle {
width: 0px;
height: 60px;
color: rgba(255, 255, 255, 0.144);
border-radius: 7%;
border: none;
transition: width 1.1s ease 0s;
transition-timing-function: ease;
transition-delay: 0s;
position: absolute;
z-index: 1;
}
.rectangle button:hover {
width: 200px;
}
Thanks.
<button> Button </button>
button{
transition:0.2s;
}
button:hover{
width:200px
}
You can add the transform property in the button CSS class. This will work to increase the size of the rectangle. You can adjust the value inside the scale to get the desired size when hovered. Copy the CSS & HTML codes below to have that working.
CSS:
.sidebar>button {
margin: 20px;
/* marge de 30px entre les boutons */
width: 200px;
height: 60px;
max-height: 60px !important;
max-width: 200px !important;
background-color: #F5FAD2;
text-align: center;
font-size: 24px;
border-radius: 7%;
border: none;
transition-duration: 0.4s;
cursor: pointer;
color: #404040;
position: relative;
}
.btn:hover {
width: 300px;
transform: scale(1.3) perspective(0.4px);
}
.rectangle {
color: rgba(255, 255, 255, 0.144);
border-radius: 7%;
border: none;
position: absolute;
z-index: 1;
}
HTML:
<div class="flex-container">
<div class="sidebar">
<button style="margin-top: 100px;" class="btn">
<div style="z-index: 2;">Accueil</div>
</button>
<div class="rectangle" name="acc" style="top: 100px;"></div>
<button class="btn">
<div style="z-index: 2;">Thés</div>
</button>
<div class="rectangle" name="the" style="top: 100px;"></div>
<button class="btn">
<div style="z-index: 2;">Tisanes</div>
</button>
<div class="rectangle" name="tis" style="top: 100px;"></div>
<button class="btn">
<div style="z-index: 2;">Théières</div>
</button>
<div class="rectangle" name="thei" style="top: 100px;"></div>
</div>
</div>
Hope this solution helps you!
Maybe it will be useful to you
.rectangle-out {
display: inline-block;
vertical-align: middle;
-webkit-transform: perspective(1px) translateZ(0);
transform: perspective(1px) translateZ(0);
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
position: relative;
background: #e1e1e1;
-webkit-transition-property: color;
transition-property: color;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
padding:20px;
color:#000;
text-decoration: none;
}
.rectangle-out:before {
content: "";
position: absolute;
z-index: -1;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: #2098D1;
-webkit-transform: scale(0);
transform: scale(0);
-webkit-transition-property: transform;
transition-property: transform;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
-webkit-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
.rectangle-out:hover, .rectangle-out:focus, .rectangle-out:active {
color: white;
}
.rectangle-out:hover:before, .rectangle-out:focus:before, .rectangle-out:active:before {
-webkit-transform: scale(1);
transform: scale(1);
}
<a class="rectangle-out" href="#">Rectangle Out</a>
Maybe it will be useful to you.
visit my GitHub page. my website total source code here. many Animation when hovering over a button
here.
https://github.com/jacksonkasi0/mhibuddy
(or) visit my website: https://mahibuddy.me
(or)
HTML:
<div class="lo">
<ul>
<li>
<a href="./love/love.html" target="_blank">
<i class="fa fa-heart"></i>
</a>
</li>
</ul>
</div>
CSS:
.lo ul {
margin: 0;
padding: 0;
display: flex;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);}
.lo > ul > li {
list-style: none;
margin: 0 15px;}
.lo > ul > li > a {
position: relative;
display: block;
width: 60px;
height: 60px;
text-align: center;
line-height: 63px;
background: #333;
border-radius: 50%;
font-size: 30px;
color: #666;
transition: 0.5s;}
.lo>ul>li>a :hover{
position: relative;
display: block;
width: 60px;
height: 60px;
text-align: center;
line-height: 63px;
background: rgb(255, 255, 255);
border-radius: 50%;
font-size: 30px;
/* color: #666; */
transition: 0.3s;}
.lo > ul > li > a::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 50%;
background: #ff05de;
transition: .5s;
transform: scale(.9);
z-index: -1;}
.lo > ul > li > a:hover::before {
transform: scale(1.1);
box-shadow: 0 0 15px #ff6e9e;}
.lo > ul > li > a:hover {
color: #ff1058;
box-shadow: 0 0 5px #ff1088;
text-shadow: 0 0 5px #ff1044;}
I think I have what you are looking for now
.flex-container {
display: flex;
flex-direction: row;
justify-content: center;
}
.rectangle {
display: none;
}
.button {
width: 200px;
height: 60px;
background-color: #F5FAD2;
text-align: center;
font-size: 24px;
border-radius: 7%;
border: none;
transition-duration: 0.4s;
cursor: pointer;
color: #404040;
position: relative;
margin-right: 20px;
}
.button:hover + .rectangle {
display: block;
width: 200px;
}
<div style="text-align:center" class="flex-container">
<div class = "button">Accueil</div>
<div class="rectangle">test</div>
<div class = "button">Thés</div>
<div class="rectangle">test</div>
<div class = "button">Tisanes</div>
<div class="rectangle">test</div>
<div class = "button">Théières</div>
<div class="rectangle">test</div>
</div>
You can checkout the fiddle I made with this info here: https://jsfiddle.net/mbmarketing4you/j92mgsy6/46/
You have to make the "rectangle" a child of the button in order for the hover effect to work.

Why is the width of my CSS animation dependent on previous HTML or CSS features?

So I'm trying to have an underline that goes the width of each text. E.g. I have headers "Team" and "Schedule", and I want the underline to go the full length of each word despite them being different lengths. This is my current code (I've included most all of the code):
html,
body {
margin: 0;
}
.menu {
position: relative;
transition: 0.3s;
z-index: 2;
}
.change .menu {
background-color: white;
width: 60vh;
height: 100vh;
color: black;
position: absolute;
top: -10px;
left: -30px;
z-index: 2;
box-shadow: 0px 8px 16px 0px;
}
.header {
position: fixed;
font-size: 20px;
top: 8px;
left: 16px;
font-family: 'Bebas Neue', cursive;
text-align: left;
color: black;
padding: 10px;
}
.change .content {
position: relative;
}
.menu a {
opacity: 0%;
}
.change .menu a {
opacity: 100%;
color: black;
text-decoration: none;
display: block;
position: relative;
left: 100px;
bottom: -50px;
font-size: 30px;
font-family: 'Bebas Neue', cursive;
z-index: 2;
}
.content h3 {
opacity: 0%;
}
.underbar {
position: relative;
}
.underbar:after {
content: '';
position: absolute;
width: 0;
height: 3px;
display: block;
margin-top: 0px;
right: 0;
background: #24478f;
transition: width .5s ease;
-webkit-transition: width .5s ease;
}
. .underbar:hover:after {
width: 12%;
left: 0;
background: #24478f;
}
.sub_underbar {
position: relative;
}
.sub_underbar:after {
content: '';
position: absolute;
width: 0;
height: 3px;
display: block;
margin-top: 5px;
right: 0;
background: #ffcc00;
transition: width .5s ease;
-webkit-transition: width .5s ease;
}
.sub_underbar:hover:after {
width: 38% left: 0;
background: #ffcc00;
}
<div class="container">
<img src="team_sunset.JPG" alt="Team Picture" style="width:100%;">
<div class="centered" style="font-size:20vw;">UMWSC</div>
<div class="header" onclick="myFunction(this)">
<div class="line1"></div>
<div class="line2"></div>
<div class="line3"></div>
<div class="menu" id="menu_scroll">
<div class="content">
HOME
<h3 class="sub_underbar">MISSION STATEMENT</h3>
<h3 class="sub_underbar">CONTACT US</h3>
TEAM
<h3 class="sub_underbar">ROSTER</h3>
<h3 class="sub_underbar">LEADERSHIP</h3>
<h3 class="sub_underbar">SCHEDULE</h3>
<h3 class="sub_underbar">STATS</h3>
NEWS
<h3 class="sub_underbar">GALLERY</h3>
<h3 class="sub_underbar">BLOG</h3>
GET INVOLVED
<h3 class="sub_underbar">MERCH</h3>
<h3 class="sub_underbar">DONATE</h3>
<h3 class="sub_underbar">PARTNER WITH US</h3>
<h3 class="sub_underbar">WORK WITH US</h3>
MORE INFO
<h3 class="sub_underbar">FORMS</h3>
<h3 class="sub_underbar">FAQS</h3>
</div>
</div>
<div id="scroll_header">
<h4>UMWSC</h4>
</div>
</div>
</div>
I think currently the width is dependent on some parent feature because when you hover to the right of the text, there's a specific spot that "triggers" the animation of the underline to occur.
I'm sure there's a lot wrong with my previous code that might be causing this current issue. Any help would be greatly appreciated! Thank you.
EDIT: The picture shows how the underline goes past the width I want it to go, I just want it to be the length of the word 'HOME'. drop-down content picture
If I'm understanding this correctly you want the main menu titles underline to span across the biggest item in that group of items. If so try this:
a {
text-decoration: none;
}
.menu {
position: relative;
transition: 0.3s;
z-index: 2;
}
.change.menu {
background-color: white;
width: 60vh;
height: 100vh;
color: black;
position: absolute;
top: -10px;
left: -30px;
z-index: 2;
box-shadow: 0px 8px 16px 0px;
}
.header {
position: fixed;
font-size: 20px;
top: 8px;
left: 16px;
font-family: 'Bebas Neue', cursive;
text-align: left;
color: black;
padding: 10px;
}
.change.content {
position: relative;
}
.underbar {
position: relative;
}
.underbar:after {
content: '';
position: absolute;
width: 0;
height: 3px;
display: block;
margin-top: 0px;
right: 0;
background: #24478f;
transition: width .5s ease;
-webkit-transition: width .5s ease;
}
.underbar:hover:after {
width: 100%;
left: 0;
background: #24478f;
}
.sub_underbar {
position: relative;
}
.sub_underbar:after {
content: '';
position: absolute;
width: 0;
height: 3px;
display: block;
margin-top: 5px;
right: 0;
background: #ffcc00;
transition: 100% .5s ease;
-webkit-transition: 100% .5s ease;
}
.sub_underbar:hover:after {
width: 38% left: 0;
background: #ffcc00;
}
<div class="container">
<div class="header" onclick="myFunction(this)">
<div class="menu" id="menu_scroll">
<div class="content-holder">
<div class="content">
HOME
<h3 class="sub_underbar">MISSION STATEMENT</h3>
<h3 class="sub_underbar">CONTACT US</h3>
</div>
<div class="content">
TEAM
<h3 class="sub_underbar">ROSTER</h3>
<h3 class="sub_underbar">LEADERSHIP</h3>
<h3 class="sub_underbar">SCHEDULE</h3>
<h3 class="sub_underbar">STATS</h3>
</div>
<div class="content">
NEWS
<h3 class="sub_underbar">GALLERY</h3>
<h3 class="sub_underbar">BLOG</h3>
</div>
<div class="content">
GET INVOLVED
<h3 class="sub_underbar">MERCH</h3>
<h3 class="sub_underbar">DONATE</h3>
<h3 class="sub_underbar">PARTNER WITH US</h3>
<h3 class="sub_underbar">WORK WITH US</h3>
</div>
<div class="content">
MORE INFO
<h3 class="sub_underbar">FORMS</h3>
<h3 class="sub_underbar">FAQS</h3>
</div>
</div>
</div>
<div id="scroll_header">
<h4>UMWSC</h4>
</div>
</div>
</div>

cant get color overlay to work. what am I missing?

I need these 4 boxes in a line to have a transparent color overlay. I need the overlay to disappear when the mouse hovers over the item. The hover effect isnt a big deal, I can figure that out. I just cant get the overlay to work properly. any help is greatly appreciated as well as any general code pointers.
<section class="alltheboxes">
<nav class="blocks">
<a href><img src="http://1.bp.blogspot.com/-BOnhWvvehfc/TeALNpDgDkI/AAAAAAAAANs/XJFcw2A2kW4/s1600/terrapin-hopsecutioner.jpg">
<span>one</span></a>
<a href><img src="https://lh3.googleusercontent.com/-fI0W7blvrk0/TXFLhefMQhI/AAAAAAAAAHM/qGdorrJn9rY/s400/191858_168745176511686_168156473237223_421534_1733583_o.jpg"><span>two</span></a>
<a href><img src="https://lh6.googleusercontent.com/-FYjkHbSx_EI/TXZC8Xl6LHI/AAAAAAAAAHc/gcBMIXQsdVU/s320/IMAG0221.jpg"><span>three</span>
</a>
<a href><img src="#"><span>four</span></a>
</nav>
</section>
CSS
.blocks a {
position: relative;
display: block;
padding-right: 25%;
padding-bottom: 25%;
outline: 1px solid black;
text-decoration: none;
color: white;
font-size: 4em;
width: 25%;
box-sizing: border-box;
overflow: hidden;
float: left;
}
.blocks img {
position: absolute;
height: 100%;
z-index: 5;
display: block;
box-sizing: border-box;
}
.blocks span {
position: absolute;
bottom: 0;
z-index: 9001;
}
HTML and CSS only.
if you want to see it in action http://codepen.io/jrutishauser/pen/wBdGRd
Add a :pseudo-element to each a element with rgba() values as a background-color and change the alpha value of rgba(r, g, b, a) on :hover.
Updated CodePen
.blocks a {
position: relative;
display: block;
padding-right: 25%;
padding-bottom: 25%;
outline: 1px solid black;
text-decoration: none;
color: white;
font-size: 4em;
width: 25%;
box-sizing: border-box;
overflow: hidden;
float: left;
}
.blocks img {
position: absolute;
height: 100%;
z-index: 5;
display: block;
box-sizing: border-box;
}
.blocks span {
position: absolute;
bottom: 0;
z-index: 6;
}
.alltheboxes a:before {
position: absolute;
content: '';
width: 100%;
height: 100%;
background: rgba(255, 200, 0, 0.5);
z-index: 7;
transition: background 0.4s ease;
}
.alltheboxes a:hover:before {
background: rgba(255, 255, 255, 0);
}
<section class="alltheboxes">
<nav class="blocks">
<a href="#">
<img src="http://1.bp.blogspot.com/-BOnhWvvehfc/TeALNpDgDkI/AAAAAAAAANs/XJFcw2A2kW4/s1600/terrapin-hopsecutioner.jpg" /><span>one</span>
</a>
<a href="#">
<img src="https://lh3.googleusercontent.com/-fI0W7blvrk0/TXFLhefMQhI/AAAAAAAAAHM/qGdorrJn9rY/s400/191858_168745176511686_168156473237223_421534_1733583_o.jpg" /><span>two</span>
</a>
<a href="#">
<img src="https://lh6.googleusercontent.com/-FYjkHbSx_EI/TXZC8Xl6LHI/AAAAAAAAAHc/gcBMIXQsdVU/s320/IMAG0221.jpg" /><span>three</span>
</a>
<a href="#">
<img src="#" /><span>four</span>
</a>
</nav>
</section>
You need to add in each link with a pseudo element :after or :before with a background with the color you need and on hover the element you set the opacity to 0
a{
display: block;
position: relative;
width: 475px;
}
a:after{
background: none repeat scroll 0 0 rgba(105, 50, 20, 1);
content: "\A ";
height: 100%;
left: 0;
opacity: 0.6;
position: absolute;
top: 0;
transition: all 0.5s ease 0s;
width: 100%;
}
a:hover:after{
opacity:0;
}
<a href="#">
<img src="http://www.online-image-editor.com//styles/2014/images/example_image.png" alt="" />
</a>
http://jsfiddle.net/j4su90c4/
.blocks a::before {
content:"";
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
background:rgba(0,0,0,0.5); /*your color*/
z-index:999;
}
.blocks a:hover::before{
background:none;
}

Fade back DIV on hover- even when hovering over front DIV

I'm looking for a CSS only solution to fade an image in a back DIV when hovering over any section of the DIV, including DIVs that are in front of it.
Here is what I've been able to build so far: http://jsfiddle.net/kqo10jLb/
The CSS:
#caseouter {
position: relative;
top: 0px;
}
#casewrap2 {
background-color: #000;
}
#casetitle {
font-size: 30px;
width: 100%;
display: block;
text-transform: uppercase;
text-align: center;
padding: 10px 0px 0px 0px;
color: #fff;
margin-bottom: 0px;
}
#casethumb {
width: 100%;
display: block;
margin-bottom: -100px;
opacity: 1;
transition: .2s opacity ease .2s;
height: 100px;
}
#casesecondline {
font-size: 30px;
color: #666;
text-transform: uppercase;
margin: 0 auto;
display: block;
width: 100%;
text-align: center;
color: #fff;
margin-top: -10px;
padding: 0px;
}
#casethumb img {
width: 100%;
}
#casethumb:hover {
opacity: .75;
}
#casetitle:hover ~ #casethumb a {
opacity: .75;
}
#casesecond:hover ~ #casethumb a {
opacity: .75;
}
And the HTML:
<div id="casewrap2">
<div id="casethumb">
<a href="www.google.com">
<img src="http://ringer.tv/wp-content/uploads/2014/08/case_bravo.jpg">
</a>
</div>
</div>
<div id="caseouter">
<a href="www.google.com">
<div id="casetitle">Headline</div>
<div id="casesecondline">Subheadline</div>
</a>
</div>
As you'll see, the back image fades on hover, however, it will not fade when I hover over the headline and subheadline text. I've tried using #casetitle:hover ~ #casethumb a but I'm obviously doing something wrong. Thanks!
Is this what you're after? http://jsfiddle.net/kqo10jLb/1/
I moved the caseouter into the casewrap2 object and changed the hover to this:
#casewrap2:hover #casethumb {
opacity: .75;
}