I have multiple css transitions on different elements.
In my example, if you hover over the circle section the transitions occur on both the circle and the box color change underneath. However if you come out of the circle and into the box section, the circle transition does not occur
See fiddle for complete example: http://jsfiddle.net/Lsnbpt8r/
Heres my html:
div class="row">
<div class="col-sm-4 text-center transistion">
<div class="box">
<i class="circle-pos circle glyphicon glyphicon-home icon"></i>
<h3 class="heading">
Construction
</h3>
<p>This is how we do it</p>
</div>
</div>
<div class="col-sm-4 text-center transistion">
<div class="box">
<i class="circle-pos circle glyphicon glyphicon-wrench icon"></i>
<h3 class="heading">
Interior Design
</h3>
<p>This is how we do it</p>
</div>
</div>
<div class="col-sm-4 text-center transistion">
<div class="box">
<i class="circle-pos circle glyphicon glyphicon-thumbs-up icon"></i>
<h3 class="heading">
Service
</h3>
<p>This is how we do it</p>
</div>
</div>
</div>
Here's some of my css:
.circle {
width: 120px;
height: 120px;
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
border-radius: 50%;
background: #f3f3f3;
-webkit-transition: all 300ms linear;
-moz-transition: all 300ms linear;
-o-transition: all 300ms linear;
-ms-transition: all 300ms linear;
transition: all 300ms linear;
}
.circle:hover{
width: 100px;
height: 100px;
background: #f7f7f7;
}
.box{
border: 0px 1px 2px 1px solid #f1f1f1;
border-top: 5px solid #003176;
height: 200px;
-webkit-transition: all 300ms linear;
-moz-transition: all 300ms linear;
-o-transition: all 300ms linear;
-ms-transition: all 300ms linear;
transition: all 300ms linear;
}
.box:hover{
background-color: #135379;
}
How can I make it so that whatever part of the section is hovered on all element transitions will take place ?
Cheers in advance.
It's because the effects are applied to each element's :hover:
.circle:hover{
width: 100px;
height: 100px;
background: #f7f7f7;
}
...
.circle-pos:hover{
margin-top: -50px;
}
So, if you hover the box, but not the circle, it won't have any effect. Instead, set the transition to the :hover of the common parent container, in this case, the .box div:
Updated Fiddle
.box:hover .circle{
width: 100px;
height: 100px;
background: #f7f7f7;
}
....
.box:hover .circle-pos{
margin-top: -50px;
}
EDIT
The same with the .icon:hover { if you want, it can be .box:hover .icon{: http://jsfiddle.net/Lsnbpt8r/3/
Related
I want text on image hover just like in this website. Using CSS3
https://addapinch.com/
You can try with this (just adopt the color and the divs)
Here is the HTML:
<div class="container">
<div class="row">
<div class="col-md-3 row_cont">
<img class="image_box" src="path_to_the_image" id="image"/>
<div id="overlay">
desired text
</div>
</div>
<div class="col-md-3 row_cont">
<img class="image_box" src="path_to_the_image" id="image"/>
<div id="overlay">
desired text
</div>
</div>
<div class="col-md-3 row_cont">
<img class="image_box" src="path_to_the_image" id="image"/>
<div id="overlay">
desired text
</div>
</div>
<div class="col-md-3 row_cont">
<img class="image_box" src="path_to_the_image" id="image"/>
<div id="overlay">
desired text
</div>
</div>
</div>
</div>
Here is the CSS:
.row_cont {
position:relative;
width:95%;
height:240px;
margin-bottom: 20px;
}
.row_cont {
position:relative;
width:95%;
height:240px;
margin-bottom: 20px;
}
#image {
position:absolute;
width:95%;
height:240px;
/* background:black; */
}
#overlay {
position:absolute;
width:95%;
height:240px;
background: #fff;
opacity: 0;
-webkit-transition: all .6s ease;
-moz-transition: all .6s ease;
-ms-transition: all .6s ease;
-o-transition: all .6s ease;
transition: all .6s ease;
}
#overlay:hover {
opacity: .95;
box-shadow: 0px 0px 30px 3px #000;
}
a.link_hover {
position: relative;
top: 45%;
left: 13%;
font-size: 26px;
font-weight: 600;
text-transform: uppercase;
color: rgba(2, 103, 193, .7);
text-decoration: none;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
-ms-transition: all .3s ease;
-o-transition: all .3s ease;
transition: all .3s ease;
}
a.link_hover:hover {
color: rgba(2, 103, 193, 1);
}
.image_box:hover {
-ms-filter: blur(3px)!important;
filter: blur(3px)!important;
cursor: pointer;
}
Let me know if it is this was helpful
I have a few elements
<div class="nav-link active"><span>Element 1</span></div>
<div class="nav-link"><span>Element 2</span></div>
<div class="nav-link"><span>Element 3</span></div>
where the active would change on click and css to add a red rhombus underneath the active div:
.nav .nav-link.active span::after{
content: "";
width: 120%;
height: 0.14em;
background: red;
transform: skewX(-45deg);
list-style: 0.5em;
display: block;
margin: 0 auto;
position: relative;
left: -20px;
-webkit-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
transition: all 1s ease-in-out;
}
and would like to change the position of that red rhombus on the .nav-link by having it animate slide in from the left based on if the div contains .active. However adding:
.nav .nav-link span::after{
left: -200px;
-webkit-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
transition: all 1s ease-in-out;
}
doesn't appear to work. Is this possible or am I taking the wrong approach?
You can used translateX to animated left slide.
.nav .nav-link.active span::after{
content: "";
width: 120%;
height: 0.14em;
background: red;
transform: skewX(-45deg) translateX(100px);
list-style: 0.5em;
display: block;
margin: 0 auto;
position: relative;
left: -20px;
-webkit-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
transition: all 1s ease-in-out;
}
<div class="nav">
<div class="nav-link active"><span>Element 1</span></div>
<div class="nav-link"><span>Element 2</span></div>
<div class="nav-link"><span>Element 3</span></div>
</div>
What is the best way to vertically align content within cards, whilst still allowing them to animate on hover, to show different screens?
For example if I have cards, each with a front which is shown and a back which is faded in on hover:
<div class="items">
<div class="item">
<div class="front">
<i class="material-icons">build</i>
<span>Item 1</span>
</div>
<div class="back">hello there</div>
</div>
<div class="item">
<div class="front">
<i class="material-icons">build</i>
<span>Item 1</span>
</div>
<div class="back">hello there</div>
</div>
<div class="item">
<div class="front">
<i class="material-icons">build</i>
<span>Item 1</span>
</div>
<div class="back">hello there</div>
</div>
</div>
Then using this css:
.item {
align-items: center;
cursor: pointer;
display: flex;
flex-direction: column;
justify-content: center;
height: 200px;
background-color: tomato;
margin: 0 auto 1rem auto;
width: 200px;
position: relative;
}
.item .material-icons {
display: block;
}
.back,
.front {
opacity: 0;
position: absolute;
text-align: center;
width: 100%;
-webkit-transition: opacity .25s ease-in-out;
-moz-transition: opacity .25s ease-in-out;
-ms-transition: opacity .25s ease-in-out;
-o-transition: opacity .25s ease-in-out;
transition: opacity .25s ease-in-out;
}
.front {
opacity: 1;
}
.item:hover .front {
opacity: 0;
}
.item:hover .back {
opacity: 1;
}
.material-icons {
font-size: 5em !important;
}
However after using position absolute, my vertical centering doesn't work, and i'm pretty sure this might not be the best approach!
You can see a half working version here:
http://jsfiddle.net/kmturley/8o29y7pd/26/
Thanks!
You can use transform to do the centering. It works great with absolute position elements. You won't need flexbox at all.
position: absolute;
left: 50%; top: 50%;
transform: translate(-50%, -50%);
text-align: center;
http://jsfiddle.net/1354hzqb/
Just add a top position of 50% and transform: translate(0, -50%) to your .back, .front classes.
#import url('https://fonts.googleapis.com/css?family=Material+Icons');
.item {
cursor: pointer;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 200px;
background-color: tomato;
margin: 0 auto 1rem auto;
width: 200px;
position: relative;
}
.item .material-icons {
display: block;
}
.back,
.front {
opacity: 0;
position: absolute;
text-align: center;
width: 100%;
top: 50%;
transform: translate(0, -50%);
-webkit-transition: opacity .25s ease-in-out;
-moz-transition: opacity .25s ease-in-out;
-ms-transition: opacity .25s ease-in-out;
-o-transition: opacity .25s ease-in-out;
transition: opacity .25s ease-in-out;
}
.front {
opacity: 1;
}
.item:hover .front {
opacity: 0;
}
.item:hover .back {
opacity: 1;
}
.material-icons {
font-size: 5em !important;
}
<div class="items">
<div class="item">
<div class="front">
<i class="material-icons">build</i>
<span>Item 1</span>
</div>
<div class="back">hello there</div>
</div>
<div class="item">
<div class="front">
<i class="material-icons">build</i>
<span>Item 1</span>
</div>
<div class="back">hello there</div>
</div>
<div class="item">
<div class="front">
<i class="material-icons">build</i>
<span>Item 1</span>
</div>
<div class="back">hello there</div>
</div>
</div>
I've got a modal overlay where the css spinner rotates when first loaded, after hiding then showing again the spinner no longer rotates.
This only happens in Chrome and only happens when the spinner is not visible from the outset (ie if the div is hidden then toggled - the animation happens as expected). Is this a bug or have I missed something?
EDIT It seems to be the visibility that it doesn't like, commenting this out, everything performs as expected
It also seems to be a bug, behaves as expected in Canary 46
EDIT I've though this was a duplicate: CSS infinite animation after hidden is not resetted (Chrome), however that works in the same version of Chrome
document.getElementById('toggle').onclick = function() {
document.getElementById('loader').classList.toggle('out');
}
#holder {
margin-top: 50px;
position: relative;
height: 300px;
background: #cc0000
}
.loader {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
padding-top: 10%;
text-align: center;
background-color: #fff;
background-color: rgba(255, 255, 255, 0.5);
overflow: hidden;
visibility: visible;
opacity: 1;
-webkit-transition: opacity .5s linear;
-moz-transition: opacity .5s linear;
-o-transition: opacity .5s linear;
transition: opacity .5s linear;
}
.loader.out {
visibility: hidden;
opacity: 0;
transition: visibility 0s 0.5s, opacity 0.5s linear;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet" />
<div>
<button id="toggle">Toggle Overlay</button>
</div>
<div id="holder">
<div class="loader" id="loader">
<i class="fa fa-spinner fa-spin fa-5x"></i>
</div>
</div>
http://justxp.plutohost.net/gxx/
Try hovering the buttons.
The hover / link will only work if you hover on the head of the buttons.
Why is this happening?
This is the code:
<a href="#">
<div class="button-1">
<span class="bebas">play</span>
</div>
</a>
<a href="#">
<div class="button-1">
<span class="bebas">community</span>
</div>
</a>
<a href="#">
<div class="button-1">
<span class="bebas">account help</span>
</div>
</a>
css
.button-1 {
background-image: url("../img/buttonoff.png");
background-repeat: no-repeat;
width: 302px;
height: 82px;
margin-left: 1.4%;
margin-top: 1%;
float: left;
text-align: center;
line-height: 90px;
-webkit-transition: all 200ms ease-in-out;
-moz-transition: all 200ms ease-in-out;
-ms-transition: all 200ms ease-in-out;
-o-transition: all 200ms ease-in-out;
transition: all 200ms ease-in-out;
}
.button-1:hover {
background-image: url("../img/buttonon.png");
background-repeat: no-repeat;
width: 302px;
height: 82px;
-webkit-transition: all 200ms ease-in-out;
-moz-transition: all 200ms ease-in-out;
-ms-transition: all 200ms ease-in-out;
-o-transition: all 200ms ease-in-out;
transition: all 200ms ease-in-out;
}
I see nothing wrong with that?
I tried making the height bigger, still doesn't work.
I'm very curious about this!
You need to add a margin on your class news:
.news {
position: relative;
top: 5%;
margin-top: 65px;
}
Edit:
Bonus! Please use css3 background gradients instead of images on background of your buttons.
gradients.glrzad.com
Hope this helps, sorry if I miss interfered.
Your this div is overlayering the buttons
<div class="news">
what you can do is :
Either you add this:
<br clear="all"/> //<---add this just above the div class named "news"
or you can adjust your css for the div class news:
.news {
position: relative;
top: 24%;
}