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

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;
}

Related

How to make pull up effect during hovering element? Just see this code once

I am trying to create an effect when div class="container" is being hovered, a smooth upper transition occurs of another div from bottom. Only during hover, this should happen cause I want that .bottom div to be hidden. When that div is not hidden, I can see the effect as I want. But as I hide the bottom div, that hovering effect smooth transition effect cannot be seen. Check this code once.
HTML CODE
<div class="box">
Hello
<div class="bottom">
Everyone
</div>
</div>
CSS code
.box{
border: 1px solid black;
display: inline-block;
border-radius: 3px;
padding: 8px;
font-size: 20px;
}
.bottom {
background: pink;
width: 80px;
text-align: center;
position: absolute;
top:80px;
left:0;
/* display: none; */
}
.box:hover .bottom {
display: block;
transition: linear 0.2s;
top:55px;
}
Here is the codepen link
https://codepen.io/Biebk/pen/MWpREqb
First off, rather than display: none to hide the incoming element altogether, you can set its opacity to 0, and then when the parent is hovered, set it to 1, like so:
.bottom {
opacity: 0;
}
.box:hover .bottom {
opacity: 1;
}
I suppose that given you want an incoming "pull-up" effect on hover, you want to that element to also "pull-down" when the hover ends. You can reverse the same effect by using a :not(:hover) on the parent element:
.box:not(:hover) .bottom {
opacity: 0;
}
Also, be sure to set the transition on the non-hovered state. The following example provides the smooth transition you're looking for:
.box {
border: 1px solid black;
display: inline-block;
border-radius: 3px;
padding: 8px;
font-size: 20px;
}
.bottom {
background: pink;
width: 80px;
text-align: center;
position: absolute;
left: 0;
transition: all .25s ease;
}
.box:not(:hover) .bottom {
top: 80px;
opacity: 0;
}
.box:hover .bottom {
top: 55px;
opacity: 1;
}
<div class="box">
Hello
<div class="bottom">
Everyone
</div>
</div>
A secondary approach would be to place the bottom div as a sibling to the box, and use the adjacent sibling combinator to apply the hover effects:
.box {
border: 1px solid black;
display: inline-block;
border-radius: 3px;
padding: 8px;
font-size: 20px;
}
.bottom {
font-size: 20px;
background: pink;
width: 80px;
text-align: center;
position: absolute;
left: 0;
top: 80px;
opacity: 0;
cursor: default;
transition: all .25s ease;
}
.box:hover + .bottom {
top: 55px;
opacity: 1;
}
<div class="box">
Hello
</div>
<div class="bottom">
Everyone
</div>
Use opacity property rather than display to achieve the desired effect, then
use the following code
.box {
border: 1px solid black;
display: inline-block;
border-radius: 3px;
padding: 8px;
font-size: 20px;
}
.bottom {
background: pink;
width: 80px;
text-align: center;
position: absolute;
top: 80px;
left: 0;
opacity: 0;
}
.box:hover .bottom{
opacity: 1;
transition: opacity 0.2s , top 1s;
top: 55px;
}
Use the following code.
.box {
border: 1px solid black;
display: inline-block;
border-radius: 3px;
padding: 8px;
font-size: 20px;
}
.hovered{
transition: all .2s;
}
.bottom {
background: pink;
width: 80px;
text-align: center;
position: absolute;
top: 80px;
left: 0;
visibility: hidden;
}
.hovered:hover+.bottom {
transition: all .2s;
top: 55px;
visibility: visible;
}
<div class="box">
<div class="hovered">Hello</div>
<div class="bottom">
Everyone
</div>
</div>

divider not showing with onhover effects

I am just attempting a simple fix. For some reason my divider isn't showing up on hover? How can I get it to show up like the other text does? I have another example of how i got the divider to look on other pages...
http://runningfish.net/finestc/about/
Right underneath the header of the page that says "About"
Also, what I am currently working with is runningfish.net/finestc
You can see the live code there right underneath the section that says "Recent Sales".
I am still a fledgling coder so if I am doing something inefficiently or could be doing better that you notice, please point it out! I want to get better at coding. Critique welcome!
Thanks!
.grids {
width: 33.33%;
float: left;
display: inline-block;
position: relative;
}
.grids img {
display: block;
height: 33.33vh;
width: 100%;
}
.grid-image-description {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.6);
color: #fff;
visibility: hidden;
opacity: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
transition: opacity .5s, visibility .5s;
}
.grid-image-description h2 {
font-family: playfairdisplay;
font-size: 1.7em;
color: #fff;
}
.grid-image-description p {
font-family: playfairdisplay;
font-size: 1.0em;
color: #fff;
}
.grid-image-description hr {
border-top: 1px;
border-color: #001532;
border-style: solid;
box-shadow: 2px 1px 15px #fff;
margin: 0 0 0 10px;
max-width: 200px;
}
.grids:hover .grid-image-description {
visibility: visible;
opacity: 1;
}
.grids-description {
transition: .5s;
transform: translateY(1em);
}
.grids:hover .grid-image-description {
transform: translateY(0);
}
<a href="#nogo">
<div class="grids">
<img class="grid-image-cover" alt="" src="//runningfish.net/finestc/wp-content/uploads/2018/02/Depositphotos_11636543_original.jpg" />
<div class="grid-image-description">
<h2 class="grids-header">House For Sale</h2>
<hr>
<p class="grids-description">123 mulbury street</br>san diego, ca 92101
</p>
</div>
</div>
</a>
Add a width value to <hr>
.grids {
width: 33.33%;
float: left;
display: inline-block;
position: relative;
}
.grids img {
display: block;
height: 33.33vh;
width: 100%;
}
.grid-image-description {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.6);
color: #fff;
visibility: hidden;
opacity: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
transition: opacity .5s, visibility .5s;
}
.grid-image-description h2 {
font-family: playfairdisplay;
font-size: 1.7em;
color: #fff;
}
.grid-image-description p {
font-family: playfairdisplay;
font-size: 1.0em;
color: #fff;
}
.grid-image-description hr {
border-top: 1px;
border-color: #001532;
border-style: solid;
box-shadow: 2px 1px 15px #fff;
margin: 0 0 0 10px;
max-width: 200px;
/* added */
width: 200px;
}
.grids:hover .grid-image-description {
visibility: visible;
opacity: 1;
}
.grids-description {
transition: .5s;
transform: translateY(1em);
}
.grids:hover .grid-image-description {
transform: translateY(0);
}
<a href="#nogo">
<div class="grids">
<img class="grid-image-cover" alt="" src="//runningfish.net/finestc/wp-content/uploads/2018/02/Depositphotos_11636543_original.jpg" />
<div class="grid-image-description">
<h2 class="grids-header">House For Sale</h2>
<hr>
<p class="grids-description">123 mulbury street<br>san diego, ca 92101
</p>
</div>
</div>
</a>

Gallery hover issues

Hi Im trying to add a hover to my gallery images but I think somewhere some code is preventing it from working. Cant work out what it is though. Help would be awesome. Im just pasting html for the first image
<div class="images">
<h1>Work</h1>
<div class="responsive">
<div class="gallery">
<a target="_blank" href="images/thumb_diesel.jpg">
<img src="images/thumb_diesel.jpg" alt="Diesel Car">
<div class="overlay">
<h6>Diesel Car</h6>
<div class="view">View Case Study</div>
</div>
</a>
</div>
</div>
.images {
width:78%;
margin-left: auto;
margin-right: auto;
}
.gallery {
position: relative;
}
div.gallery img {
width: 100%;
height: auto;
}
.overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
width: 100%;
opacity: 0;
transition: .5s ease;
background-color: rgba(0,0,0,0.8);
}
.overlay:hover .overlay {
opacity: 1;
}
h6 {
text-align: center;
font-family: 'Raleway', sans-serif;
font-weight: 700;
font-size: 45px;
color: #fff;
line-height: 1px;
padding-top: 30px;
}
.view {
text-align: center;
font-family: 'Raleway', sans-serif;
font-weight: 700;
line-height: 1px;
border-color: #fff;
border: 5px;
padding: 30px;
margin-left: 90px;
margin-right: 90px;
color: #fff;
font-size: 20px;
}
Thanks
Steve
.gallery:hover .overlay {
opacity: 1;
Please checkout JS Bin
To make the hover work you need to change the following code in your css:
.overlay:hover .overlay {
opacity: 1;
}
to:
.overlay:hover {
opacity: 1;
}
If you want the text "Diesel Car" to be displayed when someone hovers over the image then you need to add the title attribute to the img tag.
Thus your img tag would be like:
<img src="images/thumb_diesel.jpg" alt="Diesel Car" title="Diesel Car">
The alt attribute doesn't work on some webkit-based browsers.

How can I hide an image on a HTML page until a user hovers over it using CSS?

Currently, I have a website where images are clashing with the text over it.
I'm new to HTML/CSS and have looked around online but haven't ha dmuch luck. Basically, when a user isn't hovered over a box, an image should show a bit faded with text on top. When the use is hovered over the box, the image should be?
.showcase {
overflow: hidden;
margin-left: -1px;
#include flexbox;
#include justify-content(center);
}
.custom_showcase {
position: relative;
padding: 1px 0 0 1px;
#include flexbox;
img {
width: 100%;
max-width: none;
}
.inside {
display: inline-block;
max-width: 100%;
width: 100%;
background: $color_1;
#include flexbox;
#include align-items(center);
}
.textblock {
padding: 20px;
}
img + .textblock {
position: absolute;
left: 50%;
top: 50%;
width: 100%;
max-width: 455px;
padding: 0 20px;
color: $color_3;
#include transform(translate(-50%,-50%));
}
h2 {
color: $color_3;
margin: 16px 0 5px;
text-transform: uppercase;
}
p {
margin: 0;
color: $color_3;
}
h2,
p {
span {
display: inline-block;
padding-left: 0;
#include transition(.4s);
}
}
.text {
width: 100%;
}
.btn_wrapper {
position: absolute;
right: 40px;
top: 50%;
#include transform(translate(0%,-50%));
.btn {
padding: 0 10px;
min-width: 140px;
text-align: center;
opacity: 0;
#include transition(.4s);
#include transform(translate(100%,0%));
/* border-color: $color_3; */
}
}
a:not(:hover) {
//h2,
//p {
// span {
// padding-right: 0 !important;
// }
//}
opacity: .5;
transition: opacity 0.5s ease;
}
a:hover {
h2,
p {
span {
padding-left: 0 !important;
}
}
.btn_wrapper {
.btn {
opacity: 1;
#include transform(translate(0%,0%));
}
}
}
This is the best I could do with the info you have provided.
Hopefully it is helpful to you.
#theBox {
width: 200px;
height: 200px;
border: 2px solid black;
}
#octocat {
width: 185px;
opacity: 0;
}
#octocat:hover {
opacity: 1;
}
<div id="theBox">
<center>
<span> Mr. Octocat right down here. </span>
<br>
<img id="octocat" src="https://upload.wikimedia.org/wikipedia/commons/9/91/Octicons-mark-github.svg">
</center>
</div>
I'm not sure of those classes, but considering the description of your problem, here's what you can probably do:-
.image-class {
opacity: 0.4;
/*This is optional*/transition: opacity 0.5s;
}
.image-class:hover {
opacity: 1;
}
Hope that helps :)
Please correct me if I misunderstood your point.
One possible solution is to set the image as the background of a div, then nest another div inside of it that matches the width and height of the image div.
Add a background color with opacity to that inside div, and your text, then set it to invisible when hovered over.
.img-box {
background: url('http://sierranewsonline.com/wp-content/uploads/2016/07/Virginia-Eaton-July-2-SNOL-Nightshade-lycianthes-rantonnetii-10404.jpg');
background-position: top center;
width: 350px;
height: 350px;
}
.text-overlay {
width: 100%;
height: 100%;
background-color: rgba(255,255,255,0.5);
text-align: center;
}
.text-overlay:hover {
opacity: 0;
}
.text-centered {
display: inline-block;
font-size: 16px;
font-weight: bold;
padding-top: 32px;
}
<div class="img-box">
<div class="text-overlay">
<span class="text-centered">Hover over the Image</span>
</div>
</div>
Try this:
#box {
width: 300px;
position: relative;
}
.imgDiv {
margin: 0;
opacity:0.2;
}
.imgDiv:hover {
opacity:1;
}
img {
width: 100%
}
span {
position: absolute;
color:#fff;
bottom: 10px;
background: #000;
}
<div id="box">
<span>Cute Animal</span>
<div class="imgDiv">
<img src="http://www.mrwallpaper.com/wallpapers/cute-bunny-1600x900.jpg">
</div>
</div>
You can nest the text in an element that wraps the image, then on :hover alter the opacity of the image and the text to hide/show.
.card {
display: inline-block;
position: relative;
}
.info {
position: absolute;
top: 0; left: 0; right: 0; bottom: 0;
display: flex;
align-items: center;
justify-content: center;
font-size: 2.5em;
opacity: 0;
}
.card:hover .info {
opacity: 1;
}
.card:hover img {
opacity: .5;
}
img {
vertical-align: top;
max-width: 300px;
}
.info, img {
transition: opacity .25s;
}
<div class="card">
<img src="http://kenwheeler.github.io/slick/img/fonz1.png">
<div class="info">some text</div>
</div>
<div class="card">
<img src="http://kenwheeler.github.io/slick/img/fonz1.png">
<div class="info">some text</div>
</div>
<div class="card">
<img src="http://kenwheeler.github.io/slick/img/fonz1.png">
<div class="info">some text</div>
</div>

Using pure HTML and CSS in modal

I found this modal http://codepen.io/imprakash/pen/GgNMXO pure html and css no js. It's all great and all but how can I make it trigger without using a button or link? I want it to pop up to welcome visitors once the website load.
<div id="popup1" class="overlay">
<div class="popup">
<h2>Here i am</h2>
<a class="close" href="#">×</a>
<div class="content">
Thank to pop me out of that button, but now i'm done so you can close this window.
</div>
</div>
i modified your codepen
body {
font-family: Arial, sans-serif;
background: url(http://www.shukatsu-note.com/wp-content/uploads/2014/12/computer-564136_1280.jpg) no-repeat;
background-size: cover;
height: 100vh;
}
h1 {
text-align: center;
font-family: Tahoma, Arial, sans-serif;
color: #06D85F;
margin: 80px 0;
}
.box {
width: 40%;
margin: 0 auto;
background: rgba(255,255,255,0.2);
padding: 35px;
border: 2px solid #fff;
border-radius: 20px/50px;
background-clip: padding-box;
text-align: center;
}
.button {
font-size: 1em;
padding: 10px;
color: #fff;
border: 2px solid #06D85F;
border-radius: 20px/50px;
text-decoration: none;
cursor: pointer;
transition: all 0.3s ease-out;
}
.button:hover {
background: #06D85F;
}
.overlay {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.7);
transition: opacity 500ms;
visibility: hidden;
opacity: 0;
}
.overlay:not(:target) {
visibility: visible;
opacity: 1;
}
.popup {
margin: 70px auto;
padding: 20px;
background: #fff;
border-radius: 5px;
width: 30%;
position: relative;
transition: all 5s ease-in-out;
}
.popup h2 {
margin-top: 0;
color: #333;
font-family: Tahoma, Arial, sans-serif;
}
.popup .close {
position: absolute;
top: 20px;
right: 30px;
transition: all 200ms;
font-size: 30px;
font-weight: bold;
text-decoration: none;
color: #333;
}
.popup .close:hover {
color: #06D85F;
}
.popup .content {
max-height: 30%;
overflow: auto;
}
#media screen and (max-width: 700px){
.box{
width: 70%;
}
.popup{
width: 70%;
}
}
<h1>Popup/Modal Windows without JavaScript</h1>
<div class="box">
<a class="button" href="#popup1">Let me Pop up</a>
</div>
<div id="popup1" class="overlay">
<div class="popup">
<h2>Here i am</h2>
<a class="close" href="#popup1">×</a>
<div class="content">
Thank to pop me out of that button, but now i'm done so you can close this window.
</div>
</div>
</div>
You could make it with animations. A quick example:
#popup1 {
animation-name: welcome;
animation-duration: 2s;
}
#keyframes welcome {
0% {
opacity: 0;
}
30% {
opacity: 0;
}
100% {
opacity: 1;
}
}
<div id="popup1" class="overlay">Hey!</div>
As the technique uses :target psuedo class, you can directly target with appending the id of that pop up element.
Try this, http://codepen.io/imprakash/pen/GgNMXO#popup1
Just appended #popup1 to target. Thus as soon as you open, popup will be targeted and opened.