I can't share a page on this, due to the page not being public. However, what I'm trying to do is create a hover effect on both a div and a H4 text element. Nothing of which seems to work for me. Here's my code:
HTML:
<div class="grid__item small--one-half medium-up--one-quarter">
<a href="/collections/hoop-earrings" class="collection-item collection-item--overlaid" data-aos="row-of-4"><div class="image-wrap">
<div class="collection-image collection-image--square lazyload" style='background-position: center center; background-image: url("https://cdn.shopify.com/s/files/1/1810/9951/collections/LDE42DSOS_Hexagon_Hoop_Earring_web_scroll_1200x_ad647924-a6b9-4c9a-b36a-7d6a3b0d0a6c_720x.jpg?v=1561755337");'>
</div>
</div>
<noscript>
<div
class="collection-image collection-image--square"
style="background-image: url(//cdn.shopify.com/s/files/1/1810/9951/collections/LDE42DSOS_Hexagon_Hoop_Earring_web_scroll_1200x_ad647924-a6b9-4c9a-b36a-7d6a3b0d0a6c_400x.jpg?v=1561755337); background-position: center center;">
</div>
</noscript>
<div class="collection-image--overlay-background"></div>
<span
class="collection-item__title collection-item__title--overlaid collection-item__title--heading collection-item__title--center">
<span>
Text Goes Here
</span>
</span>
</a>
</div>
CSS:
.collection-image--overlay-background {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #fff;
opacity: 0;
-webkit-transition: opacity 1s linear;
-moz-transition: opacity 1s linear;
-ms-transition: opacity 1s linear;
-o-transition: opacity 1s linear;
transition: opacity 1s linear;
}
.collection-item__title.collection-item__title--overlaid.collection-item__title--heading.collection-item__title--center {
opacity: 0!important;
-moz-transition: opacity .25s linear;
-webkit-transition: opacity .25s linear;
-o-transition: opacity .25s linear;
transition: opacity .25s linear;
}
#media only screen and (min-width: 768px) {
.collection-image--overlay-background:hover {
z-index: 1;
opacity: .8;
}
.collection-item__title.collection-item__title--overlaid.collection-item__title--heading.collection-item__title--center:hover {
z-index: 1;
opacity: 1;
}
}
I tried making a small snippet. See if it´s what you´re looking for.
Since you´re using the !important flag in one of your opacity rules, all the other changes after the fact will not take effect unless you also use !important. However I would not advice using !important that freely because whenever they are present such errors are a bit harder to track.
.container {
background-color: blue;
height: 100px;
}
.onHover {
background-color: red;
width: 80%;
height: 100px;
margin: 0 auto;
opacity: 0.5;
/*opacity: 0.5 !important; In your code you have
a line like this.*/
}
.onHover:hover {
opacity: 1;
}
<div class="container">
<div class="onHover">
<h4>My title Here</h4>
</div>
</div>
Related
I have an image tag in my html and below is my html element when user logins into the application it becomes blur but if user hovers on that i need to unblur it and display the text which is present in that image.How can i do this?
what i tried?
img {
transition: 0.25s filter linear;
-webkit-transition: 0.25s filter linear;
-moz-transition: 0.25s filter linear;
-o-transition: 0.25s filter linear;
position: absolute;
top: 0;
left: 0;
overflow: hidden;
display: block;
}
<img src="https://dummyimage.com/300x300" width="109" height="19" style="vertical-align:top;" border="0">
but its not working
You could add a class attribute on your <img> element that has a :hover pseudo-selector like this:
.blurred {
opacity: .5;
}
.blurred:hover {
opacity: 1;
}
This results in the element having half the opacity initially and on hover it will have it's full opacity restored.
<img class="blurred" ...otherAttrs>
You dont clearly state how you achived the blur in your question, but assuming you used filter: blur(), then this will do the trick:
Your normal img tag should haver filter: blur(Xpx); applied
When hovering (img:hover) you just apply a blur of 0 (filter: blur(0);)
img {
transition: 0.25s filter linear;
-webkit-transition: 0.25s filter linear;
-moz-transition: 0.25s filter linear;
-o-transition: 0.25s filter linear;
position: absolute;
top: 0;
left: 0;
overflow: hidden;
display: block;
filter: blur(8px);
}
img:hover{
filter: blur(0);
}
<img src="https://dummyimage.com/300x300" width="500" height="200" style="vertical-align:top;" border="0">
Just set the blur value to 0px
EDIT
I think you should use class or id like this
<!-- added id attribute -->
<img src="https://realview/view-contact-number.gif" width="109" height="19" id="blur" border="0">
#blur {
vertical-align: top;
-webkit-filter: blur(10px);
}
#blur:hover {
-webkit-filter: blur(0px);
}
I have an album cover that also has a play button on top of it.
When a user hovers over the album cover, the opacity changes to lighten the image. Likewise, when hovering over the cover, if the user then hovers over the play button, the cover opacity should remain in it's changed state.
The problem is that because I have a transition effect on the opacity, the opacity flickers when hovering back and forth over the cover and the play button.
I created a fiddle to show the issue.
How can I have it so that when initially hovering over the album cover, the opacity transitions, but then hovering over the play button, the opacity simply stays the same without re-transitioning, causing it to flicker?
.play-button-container img:hover,
.play-button:hover + .image {
opacity: .6;
}
.play-button-container img {
transition: opacity .5s ease-out;
-moz-transition: opacity .5s ease-out;
-webkit-transition: opacity .5s ease-out;
-o-transition: opacity .5s ease-out;
}
.play-button {
position: absolute;
top: 10%;
left: 10%;
font-size: 30px;
color: #fff;
z-index: 1000;
background-color: red;
}
<div class="image-container">
<div class="play-button-container">
<div class="play-button">
PLAY
</div>
<div class="image">
<img src="http://papers.co/wallpaper/papers.co-am19-tycho-art-music-album-cover-illust-simple-white-40-wallpaper.jpg" width="350">
</div>
</div>
</div>
https://jsfiddle.net/659z2ndx/1/
When you hover over the play button, you change the opacity of the div with the class image. That is what causes the flicker.
What you should do is change the opacity of the img
.play-button-container img:hover,
.play-button:hover + .image > img {
opacity: .6;
}
.play-button-container img {
transition: opacity .5s ease-out;
-moz-transition: opacity .5s ease-out;
-webkit-transition: opacity .5s ease-out;
-o-transition: opacity .5s ease-out;
}
.play-button {
position: absolute;
top: 10%;
left: 10%;
font-size: 30px;
color: #fff;
z-index: 1000;
background-color: red;
}
<div class="image-container">
<div class="play-button-container">
<div class="play-button">
PLAY
</div>
<div class="image">
<img src="http://papers.co/wallpaper/papers.co-am19-tycho-art-music-album-cover-illust-simple-white-40-wallpaper.jpg" width="350">
</div>
</div>
</div>
.pic{
position: relative;
}
.pic .texthover{
position: absolute;
bottom:3%;
display: none;
z-index: 8000;
margin: 0 0 3.2px 0;
width: 100%;
text-align: left;
padding: 5px;
background: rgba(213,12,16,1.00);
border-bottom: 1px solid white;
transition: all 2s ease;
}
.pic:hover .texthover{
display: block;
}
<ul class="list-images">
<li>
<a href="#">
<div class="pic">
<img src="1 escultura.fw.png" width="278" height="175" title="Esculturas del Prado" class="image"/>
<div class="hover" style="">
<p class="texthover"> Escultura neoclasicista hasta el XVII</p>
</div> <!--END DIV HOVER-->
</div> <!--END DIV PIC-->
</li>
I've been racking my brain over this, it must be a very simple detail that escapes my comprehension, can anybody point it out??? Thanks all. I put the transition property in the original element and still not working...
A Vanila Example of Transition and how it works. You can change as per requirements.
div.list-images a:hover {
transition: background-color 0.5s linear;
-moz-transition: background-color 0.5s linear; /* Firefox 4 */
-webkit-transition: background-color 0.5s linear; /* Safari and Chrome */
-o-transition: background-color 0.5s linear; /* Opera */
-ms-transition: background-color 0.5s linear; /* Explorer 10 */
background:#ff0000;
}
<div class="list-images">transition</div>
Using CSS transitions, I'd like to add a delay on hover, of 0.5s, in the class "activator".
After these 0.5s, it should change "content-l1" class from display:none to display:block
I've tried with this code, but doesn't work at all.
.content-l1 {
transition: 0s display;
}
.activator:hover>.content-l1 {
display: block;
transition-delay: 0.5s;
}
<div class="activator">
<div class="content-l1"> // initially: display:none whatever content here
</div>
</div>
display do not animation for transition. u can use opacity
.content-l1 {
transition: 0s;
opacity: 0;
}
.activator:hover>.content-l1 {
opacity: 1;
transition-delay: 0.5s;
}
<div class="activator">
fjhfjh
<div class="content-l1">
afsfas
</div>
</div>
but the block 'content-l1' takes place. we need use position
.activator {
position: relative;
}
.content-l1 {
position: absolute;
background-color: white;
padding: .4em;
border: 1px solid black;
transition: 0s;
opacity: 0;
}
.activator:hover>.content-l1 {
opacity: 1;
transition-delay: 0.5s;
}
<div class="activator">
fjhfjh
<div class="content-l1">
afsfas
</div>
</div>
qwewertrtw
I am experiencing an issue with CSS3 scaling and Safari (v10.0.1).
I have a selection of grid items with the following structure:
<div class="grid-inline col-12 bp1-col-6 bp3-col-3 index-grid-selector index">
<a href="">
<div class="index-grid-item">
<div class="index-grid-dummy"></div>
<img srcset=", 2x" title="" alt="">
</div>
</a>
</div>
CSS (LESS):
.index-grid-selector {
a {
.index-grid-item {
position: relative;
overflow: hidden;
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
-o-backface-visibility: hidden;
backface-visibility: hidden;
.index-grid-dummy {
padding-bottom: 100%;
}
img {
position: absolute;
top: 0;
left: 0;
-webkit-transition: all 0.25s ease-in-out;
-moz-transition: all 0.25s ease-in-out;
-ms-transition: all 0.25s ease-in-out;
-o-transition: all 0.25s ease-in-out;
transition: all 0.25s ease-in-out;
}
}
}
&:hover {
.index-grid-item {
img {
transform: scale(1.2);
-webkit-transition: all 0.25s ease-in-out;
-moz-transition: all 0.25s ease-in-out;
-ms-transition: all 0.25s ease-in-out;
-o-transition: all 0.25s ease-in-out;
transition: all 0.25s ease-in-out;
}
}
}
}
The image is positioned absolutely within the grid item container and then scaled on hover.
During the image scaling in Safari, the image enlarges slightly and appears to shift. Gaps (white lines) appear around the image. Once the animation is complete, the image sits correctly, until the hover function is removed.
I have set up a working demo here to showcase the issue.
http://www.testdomainone.co.uk/test.html
I have tried applying the folowing to the image and its parent, but the issue still occurs.
-webkit-transform-style: preserve-3d;
-webkit-transform:translate3d(0,0,0);
-webkit-transform: translateZ(0)
Does anyone know how this can be fixed?
This does not solve your specific issue using an img tag, though since you use fixed size for your images, why not use background-image
Updated with image-set to achieve the equivalent for background images as srcset does for img ... and since it is more or less only iOS Retina which use that high resolution, it will be a decent fallback for browser not supporting it
.index-grid-item {
position: relative;
overflow: hidden;
width: 200px;
height: 200px;
}
.index-grid-dummy {
padding-bottom: 100%;
background-size: 100%;
transition: transform 0.25s ease-in-out;
}
.index-grid-item:hover > div {
transform: scale(1.2);
transition: transform 0.25s ease-in-out;
}
<div class="index-grid-item">
<div class="index-grid-dummy" style="background-image: -webkit-image-set( url(http://www.testdomainone.co.uk/images/uploads/tours/39/jmc_5233-bigsur__thumb_large.jpg) 1x, url(http://www.testdomainone.co.uk/images/uploads/tours/39/jmc_5233-bigsur__thumb_large_2x.jpg) 2x );
background-image: url(http://www.testdomainone.co.uk/images/uploads/tours/39/jmc_5233-bigsur__thumb_large.jpg)"></div>
</div>
Side note, in above sample I use inline style to set the image source in the markup, as one does with the img tag, and of course this could be set in the CSS as well