CSS Button Animation getting bigger - html

I have created a button in html/less and when you hover over the button, the button will become bigger. At the moment it's very sloppy. Right when you hover over the button it gets to the bigger size, but I want it to be slower and have an animation kinda look.
Here is my code for the button in HTML and LESS:
HTML:
<div id="buttons">
dance
</div>
CSS
.btn {
border-radius: 5px;
padding: 15px 55px;
font-size: 22px;
text-decoration: none;
margin: 20px;
color: #fff;
position: relative;
display: inline-block;
}
.btn:active {
transform: translate(0px, 5px);
-webkit-transform: translate(0px, 5px);
box-shadow: 0px 1px 0px 0px;
}
.green {
background-color: #d7d7d7;
box-shadow: 3px 5px 5px #888888;
border-radius: 2px;
}
.green:hover {
background-color: #000;
/* Making button bigger on hover */
padding: 20px 60px;
}
So how can I get my button become bigger slower and have a kinda animation look?

Simply use transition for the element which you want to make effect on it, also if you want to scale it you can use transform: scale() with perspective(10px) to prevent the blurry effect on :hover event https://jsfiddle.net/7tvvmrcf/
.btn {
border-radius: 5px;
padding: 15px 55px;
font-size: 22px;
text-decoration: none;
margin: 20px;
color: #fff;
position: relative;
display: inline-block;
}
.btn:active {
transform: translate(0px, 5px);
-webkit-transform: translate(0px, 5px);
box-shadow: 0px 1px 0px 0px;
}
.green {
background-color: #d7d7d7;
box-shadow: 3px 5px 5px #888888;
border-radius: 2px;
transition: all 1s ease;
transform: scale(1);
}
.green:hover {
background-color: #000;
/* Making button bigger on hover */
transform: scale(1.5) perspective(1px)
}
<div id="buttons">
dance
</div>

You can use scaling for this. Put transition: all .5s ease-in-out; in the .green css for the slow animation and put transform: scale(1.1); in the .green:hover css for resizing the button. It will look like this:
.btn {
border-radius: 5px;
padding: 15px 55px;
font-size: 22px;
text-decoration: none;
margin: 20px;
color: #fff;
position: relative;
display: inline-block;
}
.btn:active {
transform: translate(0px, 5px);
-webkit-transform: translate(0px, 5px);
box-shadow: 0px 1px 0px 0px;
}
.green {
background-color: #d7d7d7;
box-shadow: 3px 5px 5px #888888;
border-radius: 2px;
transition: all .5s ease-in-out;
}
.green:hover {
background-color: #000;
/* Making button bigger on hover */
padding: 20px 60px;
transform: scale(1.1);
}
<div id="buttons">
Dance
</div>

This is kind of a hack where when you hover over the button, and it gets bigger or smaller without transition:
.wallpaper{
height: 200px;
width: 200px;
background-color:#F5F5F5
}
.smileyStyle{
height: 50px;
width: 50px;
border-radius: 50%;
margin-left: 10px;
border: 3px solid #F5F5F5;
}
.smileyStyle:hover{
border: none;
}
<div class="wallpaper">
<button class="smileyStyle"> :)</button>
</div>

Based on your existing code and the information you give, it looks like simply adding transition: transform,padding .5s; to your .btn selector would do the job.
I usually prefer to be specific about the properties that will be taken into account by the transition to avoid changing something unwanted because of the cascade.
.btn {
[…]
transition: transform, padding .5s;
}
.btn {
border-radius: 5px;
padding: 15px 55px;
font-size: 22px;
text-decoration: none;
margin: 20px;
color: #fff;
position: relative;
display: inline-block;
transition: transform, padding .5s;
}
.btn:active {
transform: translate(0px, 5px);
-webkit-transform: translate(0px, 5px);
box-shadow: 0px 1px 0px 0px;
}
.green {
background-color: #d7d7d7;
box-shadow: 3px 5px 5px #888888;
border-radius: 2px;
}
.green:hover {
background-color: #000;
/* Making button bigger on hover */
padding: 20px 60px;
}
<div id="buttons">
dance
</div>

Related

Why isn't my button translating correctly in my div?

I'm new to HTML/CSS and attempting to replicate this button effect in a project of mine where the buttons are children of a div. However, whenever I do the translateY, my buttons move to the side instead. Here is the HTML and CSS; button-2 is the problematic one:
.container {
position: relative width: 600px;
height: 600px;
}
#button-1 {
position: absolute;
padding: 15px 25px;
font-size: 24px;
cursor: pointer;
text-align: center;
text-decoration: none;
outline: none;
color: #fff;
background-color: #4CAF50;
border: ridge;
border-radius: 15px;
box-shadow: 0 9px #999;
top: 50%;
left: 25%;
}
#button-1:hover {
background-color: #3e8e41
}
#button-1:active {
background-color: #3e8e41;
box-shadow: 0 5px #666;
transform: translateY(10px);
}
#button-2 {
position: absolute;
width: 100px;
padding: 5px 5px;
border-style: solid;
border-width: 2px;
border-radius: 10px;
border-color: darkslategray;
background-color: antiquewhite;
box-shadow: 0px 9px gray;
cursor: pointer;
top: 62%;
left: 50%;
/* if i remove this line, translation works as expected
but then the button is no longer centered horizontally
consequently, keeping the line breaks the affect
but the button can be centered horizontally
*/
transform: translate(-50%, 0);
}
#button-2:hover {
background-color: cornsilk;
}
#button-2:active {
background-color: cornsilk;
box-shadow: 0px 3px gray;
transform: translateY(5px);
}
<h2>Animated Button - "Pressed Effect"</h2>
<div class=container>
<button id="button-1">Btn1</button>
<button id="button-2">Btn2</button>
</div>
The problem seems to stem from transform: translate(-50%, 0);, which is what I have to do to center button-2 horizontally in the container div. I can remove that line and the effect works, but then button-2 is no longer centered horizontally. Why is it that transform: translate(-50%, 0); seemingly causes the subsequent transform: translateY(5px); not to work for button-2? Is there anyway I can horizontally (but not vertically) center button-2 while also being able to achieve the desired effect?
The problem is that when you set the translate property on the second button becoming active, you overwrite the original transform which is moving the button by half its width in the negative X direction.
It is important to keep this translation as well as the new one so make the translation in the active state set both the X and Y values that you want.
.container {
position: relative width: 600px;
height: 600px;
}
#button-1 {
position: absolute;
padding: 15px 25px;
font-size: 24px;
cursor: pointer;
text-align: center;
text-decoration: none;
outline: none;
color: #fff;
background-color: #4CAF50;
border: ridge;
border-radius: 15px;
box-shadow: 0 9px #999;
top: 50%;
left: 25%;
}
#button-1:hover {
background-color: #3e8e41
}
#button-1:active {
background-color: #3e8e41;
box-shadow: 0 5px #666;
transform: translateY(10px);
}
#button-2 {
position: absolute;
width: 100px;
padding: 5px 5px;
border-style: solid;
border-width: 2px;
border-radius: 10px;
border-color: darkslategray;
background-color: antiquewhite;
box-shadow: 0px 9px gray;
cursor: pointer;
top: 62%;
left: 50%;
/* if i remove this line, translation works as expected
but then the button is no longer centered horizontally
consequently, keeping the line breaks the affect
but the button can be centered horizontally
*/
transform: translate(-50%, 0);
}
#button-2:hover {
background-color: cornsilk;
}
#button-2:active {
background-color: cornsilk;
box-shadow: 0px 3px gray;
transform: translate(-50px, 5px);
}
<h2>Animated Button - "Pressed Effect"</h2>
<div class=container>
<button id="button-1">Btn1</button>
<button id="button-2">Btn2</button>
</div>
Note: as others have suggested you may like to look into using flex (or grid) to position your buttons rather than having to mess around with positioning using absolute and translations. The translate for Y could then remain as in the original and you wouldn't be translating in the X direction at all.
you have gotten your X and Y axis mixed up.
you translated via translate(-50%, 0) which moves it by an X of -50% and a Y of nothing, you can fix this by changing it to translate(0, -50%) which will move it down a Y of -50%, and an X of 0.
test the snippet:
.container {
position: relative width: 600px;
height: 600px;
}
#button-1 {
position: absolute;
padding: 15px 25px;
font-size: 24px;
cursor: pointer;
text-align: center;
text-decoration: none;
outline: none;
color: #fff;
background-color: #4CAF50;
border: ridge;
border-radius: 15px;
box-shadow: 0 9px #999;
top: 50%;
left: 25%;
}
#button-1:hover {
background-color: #3e8e41
}
#button-1:active {
background-color: #3e8e41;
box-shadow: 0 5px #666;
transform: translateY(10px);
}
#button-2 {
position: absolute;
width: 100px;
padding: 5px 5px;
border-style: solid;
border-width: 2px;
border-radius: 10px;
border-color: darkslategray;
background-color: antiquewhite;
box-shadow: 0px 9px gray;
cursor: pointer;
top: 62%;
left: 50%;
/* if i remove this line, translation works as expected
but then the button is no longer centered horizontally
consequently, keeping the line breaks the affect
but the button can be centered horizontally
*/
transform: translate(0, -50%);
}
#button-2:hover {
background-color: cornsilk;
}
#button-2:active {
background-color: cornsilk;
box-shadow: 0px 3px gray;
transform: translateY(5px);
}
<h2>Animated Button - "Pressed Effect"</h2>
<div class=container>
<button id="button-1">Btn1</button>
<button id="button-2">Btn2</button>
</div>

Edge browser: Jerking movement at the end of transition only when skew and translate are used together

I have a position:absolute element behind my anchor tag. I animate that element with simple css transition when the anchor tag is hovered.
On Edge only, there's this funky jerky movement at the very end of the transition.
I tried adding translateX(0) to both hover and normal states, but that did not remove the jerky move at the end.
Here's the button html:
.button {
display: inline-block;
border: none;
background: transparent;
position: relative;
color: #212121;
font-size: 19px;
line-height: 1;
padding: 0;
margin: 30px;
text-decoration: none;
font-weight: 400;
cursor: pointer;
z-index: 2;
transition: .3s;
transition-timing-function: cubic-bezier(.82, .21, .27, .81);
}
.button-bg {
position: absolute;
padding: 30px;
height: 50px;
border-radius: 0;
left: -30px;
right: -30px;
top: 50%;
transform: translateY(-50%);
z-index: -1;
transition: .4s;
transition-timing-function: cubic-bezier(.82, .21, .27, .81);
transform-origin: center;
border: 2px solid #212121;
}
a.button:hover .button-bg {
-webkit-transform: translateY(-50%) scaleY(2) scaleX(1.4) skewY(10deg);
transform: translateY(-50%) scaleY(2) scaleX(1.4) skewY(10deg);
-webkit-transform-origin: center;
transform-origin: center;
border: 2px solid transparent;
-webkit-box-shadow: 0px 0px 20px 0px rgba(48, 48, 48, 0.6);
-moz-box-shadow: 0px 0px 20px 0px rgba(48, 48, 48, 0.6);
box-shadow: 0px 0px 20px 0px rgba(48, 48, 48, 0.6);
}
<a class="button case-readmore" href="#">
Read Case
<span class="button-bg"></span>
</a>
Expected result can be seen with Chrome, Firefox, Internet explorer etc.
Weird bugfest can be seen with Edge, where the element transforms properly and at the very end of the transform jerks quickly to the right.
If I remove the skew part of the transition, theres no more jerking.
Try to add the default values before the hover. There is probably an interpolation issue.
.button {
display: inline-block;
border: none;
background: transparent;
position: relative;
color: #212121;
font-size: 19px;
line-height: 1;
padding: 0;
margin: 30px;
text-decoration: none;
font-weight: 400;
cursor: pointer;
z-index: 2;
transition: .3s;
transition-timing-function: cubic-bezier(.82, .21, .27, .81);
}
.button-bg {
position: absolute;
padding: 30px;
height: 50px;
border-radius: 0;
left: -30px;
right: -30px;
top: 50%;
transform: translateY(-50%) scaleY(1) scaleX(1) skewY(0deg);
z-index: -1;
transition: .4s;
transition-timing-function: cubic-bezier(.82, .21, .27, .81);
transform-origin: center;
border: 2px solid #212121;
}
a.button:hover .button-bg {
transform: translateY(-50%) scaleY(2) scaleX(1.4) skewY(10deg);
transform-origin: center;
border: 2px solid transparent;
box-shadow: 0px 0px 20px 0px rgba(48, 48, 48, 0.6);
}
<a class="button case-readmore" href="#">
Read Case
<span class="button-bg"></span>
</a>
Related:
Weird behavior when rotating an element on hover
matrix not equal to translate and rotate combination in css transform animation?
why this keyframe animation form this animation effect

Multiple Modal Box - Pure CSS

I watched the tutorial Pure CSS Animated Modal/Lightbox. I was able to get the right result even when I changed the modal's corresponding link to an image. The problem is, whenever I add another image and link it to a different modal, the bottom part of both modal shows up when I open the page. Something like this. (Image 1) This also happens when I click on the images. (Image 2) Image Link
I placed all image modal links inside a pure css tab. And here're the codes I used.
EDIT (Full CSS I'm using on my page)
body {
background-image: url('https://lh4.googleusercontent.com/-MohfCSihE2I/VGRnxqZNuFI/AAAAAAAAADE/SgiIb4GEIY8/s2048/back.gif');
background-color: white;
color: black;
font-size: 16px;
font-family: trebuchet ms, helvetica, sans-serif;
letter-spacing: 3px;
}
#font-face {
font-family: bf-font;
src: url(http://bf.amebagames.com/font/bf-font.woff") format('woff');
}
.bf {
font-family: bf-font;
}
.cardbg {
background-image: url('https://lh3.googleusercontent.com/-kV3vTS7WzFQ/Vq8iIGo8mOI/AAAAAAAADS4/qv3O9n1L0gI/s2048-Ic42/cmnTitleRed.png');
text-align: center;
color: #FFF;
border-radius: 3px;
}
.cardattri {
font-family: bf-font;
font-size: 26px;
text-align: center;
}
.cardtitle {
font-size: 20px;
color: #FFF;
text-align: center;
}
.story {
background-image: url('https://lh3.googleusercontent.com/-AVgAM5nK6ec/Vq8iIDN1uyI/AAAAAAAADSw/dThSw3Re6-E/s2048-Ic42/bg%252520brown.png');
width: 200px;
height: 26px;
margin: 0px 75px;
border-radius: 5px;
}
/* TABS */
.tabs {
list-style-type: none;
padding: 0;
margin: 0;
position: relative;
}
.tabs:after {
content: "";
clear: both;
display: block;
height: 542px;
}
.tabs li {
float: left;
}
.tabs li > input {
display: none;
}
.tabs li > label {
display: inline-block;
border: 1px solid #000;
border-right-width: 0;
border-bottom-width: 0;
height: 30px;
line-height: 30px;
padding: 5px 20px;
cursor: pointer;
}
.tabs li:last-child > label {
border-right-width: 1px;
}
.tabs .tab-content {
display: none;
position: absolute;
left: 0;
padding: 20px;
border: 1px solid #000;
width: 768px;
height: 500px;
overflow-y: scroll;
}
/* TABS Functional */
.tabs li > input:checked + label {
background-color: #DDD;
}
.tabs li > input:checked ~ .tab-content {
display: block;
}
/* MODAL */
.modal-container {
position: fixed;
background-color: #FFF;
background-image: url('https://lh3.googleusercontent.com/-J73bzJ9PVJE/Vq8iIGmBxlI/AAAAAAAADS0/-uNM7fG2sI4/s2048-Ic42/bg_new%252520no%252520border%2525202.png');
width: 100%;
max-width: 350px;
height: 100%;
max-height: 550px;
left: 50%;
padding: 5px;
border: 2px solid #512d2d;
border-radius: 5px;
-webkit-transform: translate(-50%, 200%);
-ms-transform: translate(-50%, 200%);
transform: translate(-50%, 200%);
-webkit-transition: -webkit-transform 200ms ease-out;
transition: transform 200ms ease-out;
}
.modal:before {
content: "";
position: fixed;
display: none;
background-color: rgba(0,0,0,.8);
top: 0;
left: 0;
height: 100%;
width: 100%
}
.modal:target:before {
display: block;
}
.modal:target .modal-container {
top: 18%;
-webkit-transform: translate(-50%, 0);
-ms-transform: translate(-50%, 0);
transform: translate(-50%, 0);
}
a.boxclose {
float: right;
margin-right: -18px;
margin-top: -16px;
width: 22px;
height: 22px;
text-align: center;
text-decoration: uppercase;
color: #947a4e;
font-size: 20px;
border-radius: 12px;
background-color: #FFF;
box-shadow: 0px 0px 2px
rgba(0,0,0,0.4);
}
a.boxclose:link {
text-decoration: none;
}
.boxclose::before {
content: "";
}
#modal-close {}
/* CARD ANIMATION */
.panel {
width: 350px;
height: 438px;
margin: auto;
position: relative;
-moz-border-radius: 0px 50px 0px 50px;
-webkit-border-radius: 0px 50px 0px 50px;
-o-border-radius: 0px 50px 0px 50px;
border-radius: 0px 50px 0px 50px;
-webkit-transition: all .7s ease;
-moz-transition: all .7s ease;
-o-transition: all .7s ease;
overflow: hidden;
}
.card {
width: 350px;
height: 438px;
-o-transition: all .5s;
-ms-transition: all .5s;
-moz-transition: all .5s;
-webkit-transition: all .5s;
transition: all .5s;
-webkit-backface-visibility: hidden;
-ms-backface-visibility: hidden;
-moz-backface-visibility: hidden;
backface-visibility: hidden;
position: absolute;
top: 0px;
left: 0px;
}
.front {
z-index: 2;
background-repeat: no-repeat;
width: 230px;
-moz-border-radius: 0px 50px 0px 50px;
-webkit-border-radius: 0px 50px 0px 50px;
-o-border-radius: 0px 50px 0px 50px;
border-radius: 0px 50px 0px 50px;
}
.back {
z-index: 1;
-webkit-transform: rotateY(180deg);
-ms-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
transform: rotateY(180deg);
background-repeat: no-repeat;
width: 230px;
-moz-border-radius: 50px 0px 50px 0px;
-webkit-border-radius: 50px 0px 50px 0px;
-o-border-radius: 50px 0px 50px 0px;
}
.panel:hover {
-moz-border-radius: 50px 0px 50px 0px;
-webkit-border-radius: 50px 0px 50px 0px;
-o-border-radius: 50px 0px 50px 0px;
border-radius: 50px 0px 50px 0px;
-webkit-transition: all .7s ease;
-moz-transition: all .7s ease;
-o-transition: all .7s ease;
overflow: hidden;
}
.panel:hover .front {
z-index: 1;
-webkit-transform: rotateY(-180deg);
-ms-transform: rotateY(-180deg);
-moz-transform: rotateY(-180deg);
transform: rotateY(-180deg);
}
.panel:hover .back {
z-index: 2;
-webkit-transform: rotateY(0deg);
-ms-transform: rotateY(0deg);
-moz-transform: rotateY(0deg);
transform: rotateY(0deg);
}
HTML code
<ul class="tabs">
<li>
<input type="radio" name="tabs" id="king" checked>
<label for="king">King</label>
<div class="tab-content">
<img src="https://lh3.googleusercontent.com/-REZUMNTK5vA/VINOSxepDYI/AAAAAAAACA4/2ixTyaJIp4U/s2048-Ic42/1a.jpg" width="250px"><br>
<img src="https://lh3.googleusercontent.com/-e2gN0x-vlr8/VVDGF5XpVzI/AAAAAAAACA4/b1SibabLkpA/s2048-Ic42/11a.jpg" width="250px">
<div class="modal" id="saku">
<div class="modal-container">
<span class="bf">x</span>
<div class="cardbg">
<span class="cardattri">q</span>
<span class="cardtitle">[ミダラな寝相] Saku Kagami (SSR)</span>
</div><br>
<div class="story" style="font-size: 14px; text-align: center;"><img src="https://lh3.googleusercontent.com/-UFyiWZmr1AA/VGRnyG-RtQI/AAAAAAAAADU/LWENjijPlMA/s2048-Ic42/icon_story.png" width="14px" height="16px"> 何を想像した?</div><br>
<div class="panel">
<div class="front card">
<img src="https://lh3.googleusercontent.com/-REZUMNTK5vA/VINOSxepDYI/AAAAAAAACA4/2ixTyaJIp4U/s2048-Ic42/1a.jpg" alt="SSR1 Card" width="350px" height="438px">
</div>
<div class="back card">
<img src="https://lh3.googleusercontent.com/-r3CHpi4DxSw/VfVhhUpmDaI/AAAAAAAACA4/VldO2dZdhno/s2048-Ic42/1c.jpg" alt="SSR 1 CG" width="350x" height="438px">
</div>
</div><br>
</div>
</div>
<div class="modal" id="ssr">
<div class="modal-container">
<span class="bf">x</span>
<div class="cardbg">
<span class="cardattri">q</span>
<span class="cardtitle">[ミダラな寝相] Saku Kagami (SSR)</span>
</div><br>
<div class="story" style="font-size: 14px; text-align: center;"><img src="https://lh3.googleusercontent.com/-UFyiWZmr1AA/VGRnyG-RtQI/AAAAAAAAADU/LWENjijPlMA/s2048-Ic42/icon_story.png" width="14px" height="16px"> 何を想像した?</div><br>
<div class="panel">
<div class="front card">
<img src="https://lh3.googleusercontent.com/-e2gN0x-vlr8/VVDGF5XpVzI/AAAAAAAACA4/b1SibabLkpA/s2048-Ic42/11a.jpg" alt="SSR1 Card" width="350px" height="438px">
</div>
<div class="back card">
<img src="https://lh3.googleusercontent.com/-d_7dx1qF0Pc/VfViJRPBiEI/AAAAAAAACA4/UairgGEi-jc/s2048-Ic42/11c.jpg" alt="SSR 1 CG" width="350x" height="438px">
</div>
</div><br>
</div>
</div>
</div>
</li>
</ul>
How do I fix this?
Note: The modal contains a lot of div because I included a card animation on the content.
If you replace the images inside the anchor tags with just standard text it works fine, as so:
Link One
Link Two
The issue is therefore likely to be in your CSS, where something is conflicting, with the image elements you are putting inside.
You might need to post your full code so people on here can get a bit of a better idea as to what is going on.

Issue with Chrome and Transform

As you may see in the video (link bellow) I have an animaton that makes that an images moves with the mouse over.
It works fine with all browsers but I have a problem.
When I use and I click on "Información rápida" and then close the popup, the image disapears, and I can only see basic information of the property and a white space.
After closing he popup I should see the image again and the basic information when the mouse is over.
I'd like to know if it is a problem with my code or if there is an issue with Chrome and Transform.
This only occurs with Chrome browser.
The code is use for this in my css file is:
.ngm-thumb .mask {
background-color: #fff;
opacity: 1;
-webkit-transform: translateY(206px);
-moz-transform: translateY(206px);
-o-transform: translateY(206px);
-ms-transform: translateY(206px);
transform: translateY(206px);
transition: all 0.3s ease-in-out 0s;
I copy and paste my html code at the bottom.
Any idea?
I use Chrome v. 45.0.2454.101 m
If you think it is a coding error, any suggestion to fix this?
Link to the video: https://youtu.be/5Gp-0WpC_jQ
Site link: http://www.quieroapartamento.com/es/
Thanks for your help.
My complete CSS code in template.css for ngm-thumb class
.ngm-thumb {
border: 1px solid #ebebeb;
-webkit-box-shadow: 0 3px 3px #cccccc;
-moz-box-shadow: 0 3px 3px #cccccc;
box-shadow: 0 3px 3px #cccccc;
float: left;
height: 261px;
overflow: hidden;
position: relative;
width: 100%;
margin-bottom: 50px;
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
}
.ngm-thumb .mask {
height: 261px;
left: 0;
overflow: hidden;
position: absolute;
top: 0;
width: 100%;
}
.ngm-thumb a > img {
border-bottom: 1px solid #ebebeb;
display: block;
position: relative;
width: 100%;
}
.ngm-thumb .main {
border-bottom: 1px solid #ebebeb;
height: 55px;
}
.ngm-thumb .main h5 {
display: inline-block;
font-size: 14px;
font-weight: bold;
padding: 10px 0 0 20px;
position: relative;
}
.ngm-thumb .main .price {
border-color: -moz-use-text-color #ebebeb #ebebeb;
border-style: none solid solid;
border-width: medium 1px 1px;
display: inline;
float: right;
font-size: 18px;
font-weight: bold;
height: 55px;
padding: 6px 25px;
background-color: rgba(90, 186, 198, 0.05);
color: #75c5cf;
}
.ngm-thumb .main .price span {
color: #979797;
display: block;
font-size: 11px;
font-weight: normal;
text-align: center;
}
.ngm-thumb .content {
padding: 20px;
position: relative;
text-align: left;
}
.ngm-thumb .content button {
margin-top: 5px;
}
.ngm-thumb .content p span {
display: block;
font-weight: bold;
}
.ngm-thumb .content i {
padding-right: 5px;
}
.ngm-thumb img {
transition: all 0.3s ease-in-out 0s;
}
.ngm-thumb .mask {
background-color: #fff;
opacity: 1;
-webkit-transform: translateY(206px);
-moz-transform: translateY(206px);
-o-transform: translateY(206px);
-ms-transform: translateY(206px);
transform: translateY(206px);
transition: all 0.3s ease-in-out 0s;
}
.ngm-thumb:hover .mask {
-webkit-transform: translateY(0px);
-moz-transform: translateY(0px);
-o-transform: translateY(0px);
-ms-transform: translateY(0px);
transform: translateY(0px);
}
.ngm-thumb:hover a > img {
-webkit-transform: translateY(-206px);
-moz-transform: translateY(-206px);
-o-transform: translateY(-206px);
-ms-transform: translateY(-206px);
transform: translateY(-206px);
}
#media (min-width: 992px) and (max-width: 1199px) {
.ngm-thumb {
font-size: 12px;
}
.ngm-thumb,
.ngm-thumb .mask {
width: 100%;
height: 261px;
}
.ngm-thumb .main .price {
padding: 10px;
font-size: 12px;
border-right: none;
}
.ngm-thumb .main,
.ngm-thumb .main .price {
height: 55px;
}
.ngm-thumb .mask {
background-color: #fff;
-webkit-transform: translateY(206px);
-moz-transform: translateY(206px);
-o-transform: translateY(206px);
-ms-transform: translateY(206px);
transform: translateY(206px);
This is my html code:
<patTemplate:tmpl name="pageoutput" unusedvars="strip">
{JOMRES_POPUPURL_GLOBALVAR}
<div title="{PROPERTY_NAME}" class="col-xs-12 col-sm-12 col-md-6 col-lg-4 appear" data-animated="flipInX" data-start="{ANIMATION_DELAY}">
<div class="ngm-thumb">
<img src="{IMAGEMEDIUM}" alt="{PROPERTY_NAME}" title="{PROPERTY_NAME}" class="img-responsive" />
<div class="mask">
<div class="main">
<h5>{PROPERTY_NAME} {STARSIMAGES} {SUPERIOR}</h5>
<div class="price">
{PRICE_PRICE} <span>{PRICE_POST_TEXT}</span>
</div>
</div>
<div class="content">
<p>{PROPERTY_STREET}, {PROPERTY_TOWN}, {PROPERTY_POSTCODE}, {PROPERTY_REGION}, {PROPERTY_COUNTRY}</p>
{QUICKINFORMATION}
{MOREINFORMATION}
</div>
</div>
</div>
</div>
<script>
jomresJquery(document).ready(function(){
jomresJquery('#module_{RANDOM_IDENTIFIER}_popup').appendTo("body");
});
</script>
<div class="modal fade" id="module_{RANDOM_IDENTIFIER}_popup"></div>
</patTemplate:tmpl>

CSS transition fade out using opacity is not working

I am trying to have a div where on hover the image fades out (so you can only see the gray background behind) and some text fades in. I have been trying to do this using CSS transitions, however the opacity does not seem to change (i.e. I can still see the background image).
HTML:
<div id='options'>
<div class='option'>
<div class='back-option'>
</div>
<div class='front-option'>
Add post
</div>
</div>
</div>
CSS:
#options {
font-family: 'Segoe UI', 'Arial', sans-serif;
}
.option {
position: relative;
width: 6.25em;
height: 6.25em;
border-radius: 5px;
cursor: pointer;
background-color: #363636;
}
.back-option {
position: absolute;
width: 6.25em;
height: 6.25em;
border-radius: 5px;
background-image: url(http://png-5.findicons.com/files/icons/2672/pixel_ui/16/add.png);
background-size: contain;
-webkit-box-shadow: inset 0px 0px 0px 2px rgba(0,0,0,0.75);
-moz-box-shadow: inset 0px 0px 0px 2px rgba(0,0,0,0.75);
box-shadow: inset 0px 0px 0px 2px rgba(0,0,0,0.75);
opacity: 1;
transition: opacity 0.5s;
}
.back-option:hover {
opacity: 0;
}
.front-option {
position: absolute;
width: 6.25em;
height: 6.25em;
border-radius: 5px;
color: #FFFFFF;
font-weight: bold;
text-align: center;
line-height: 6.25em;
opacity: 0;
transition: opacity 0.5s;
}
.front-option:hover {
opacity: 1;
}
Here is a JSBin of it.
The hover isn't triggering because of the div placed over the top. I've simply modified the css to detect the hover on its parent instead.
.option:hover .back-option {
opacity: 0;
}
Live example: http://jsbin.com/cucadami/4/edit
.back-option doesn't get the event mouseover , cause another element is over it.
do
#options:hover .back-option {
opacity: 0;
}
and it will work.
you could as well give a background-color to .front-option, wich stands on top, and drop hover rules for .back-option