This question already has answers here:
Spin or rotate an image on hover
(5 answers)
Closed 7 years ago.
I have this code to make a rotation on hover. It doesn't work at all. What's is wrong with it?
I need the complete animation of the rotation for 360ยบ
.icon-style-1 .builder-element-icon {
height: 100px;
width: 100px;
line-height: 100px;
background: blue;
line-height: 100px;
text-align: center;
margin: 0 auto;
display: block;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
color: white;
}
.icon-style-1 .builder-element-icon:hover {
background: green;
-moz-transform: rotate(360deg);
-webkit-transform: rotate(360deg);
-o-transform: rotate(360deg);
-ms-transform: rotate(360deg);
transform: rotate(360deg);
}
<div class="icon-style-1">
<span class="builder-element-icon fa fa-camera"></span>
</div>
So here you go with transition on normal element style and rotate added on hover and External DEMO HERE
.icon-style-1 .builder-element-icon{
height: 100px;
width: 100px;
line-height: 100px;
background: blue;
line-height: 100px;
text-align: center;
margin: 0 auto;
display: block;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
color: white;
/* Firefox */
-moz-transition: all 1s ease;
/* WebKit */
-webkit-transition: all 1s ease;
/* Opera */
-o-transition: all 1s ease;
/* Standard */
transition: all 1s ease;
}
.icon-style-1 .builder-element-icon:hover{
background: green;
/* Firefox */
-moz-transform: rotate(360deg) ;
/* WebKit */
-webkit-transform: rotate(360deg);
/* Opera */
-o-transform: rotate(360deg) ;
/* Standard */
transform: rotate(360deg) ;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<div class="icon-style-1">
<div class="builder-element-icon glyphicon glyphicon-camera">
</div>
</div>
360 degrees rotates it back to its original place. you probably wanted it to be 180deg;
if you want it animatad, you need to add a transition:
.icon-style-1 .builder-element-icon{
height: 100px;
width: 100px;
line-height: 100px;
background: blue;
line-height: 100px;
text-align: center;
margin: 0 auto;
display: block;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
color: white;
-moz-transition: -moz-transform ease 0.6s;
-webkit-transition: -webkit-transform ease 0.6s;
-o-transition: -o-transform ease 0.6s;
-ms-transition: -ms-transform ease 0.6s;
transition: transform ease 0.6s;
}
.icon-style-1 .builder-element-icon:hover{
background: green;
-moz-transform: rotate(360deg);
-webkit-transform: rotate(360deg);
-o-transform: rotate(360deg);
-ms-transform: rotate(360deg);
transform: rotate(360deg);
}
<div class="icon-style-1">
<span class="builder-element-icon fa fa-camera">a</span>
</div>
and in case you want to animate the background color to, you could replace transition: transform ease 0.6s; withe either
transition: transform ease 0.6s, background ease 0.6s;
or
transition: all ease 0.6s;
You can use CSS3 transitions in order to achieve this result.
Just move your mouse over the label.
#rotatable {
font-size: 30px;
}
#rotatable:hover {
-moz-transform: rotate(360deg);
-webkit-transform: rotate(360deg);
-o-transform: rotate(360deg);
-ms-transform: rotate(360deg);
transform: rotate(360deg);
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-ms-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
<span id="rotatable">I can rotate!</span>
You forgot to add CSS Transitions. Also, you don't need to use -moz, -ms and -o vendor prefixes now, see Can I Use:
JSFiddle
.icon-style-1 .builder-element-icon {
height: 100px;
width: 100px;
line-height: 100px;
background: blue;
text-align: center;
margin: 0 auto;
display: block;
border-radius: 50%;
color: white;
-webkit-transition: all 0.5s;
transition: all 0.5s;
}
.icon-style-1 .builder-element-icon:hover {
background: green;
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet"/>
<div class="icon-style-1">
<span class="builder-element-icon fa fa-camera"></span>
</div>
Related
This question already has answers here:
Creating a Zoom Effect on an image on hover using CSS?
(13 answers)
Closed last year.
I am trying to have a text slide up with an overlay but the problem that the overlay is sliding up with the text together what i really want is the overlay to be zoom in effect with the image and the text slide up here is an exemple that i am working on and i still can't achieve it.
Codepen exemple minus the zoom in effect
.clients {
position: relative;
}
.client-container {
position: relative;
width: 100%;
overflow: hidden;
}
.client-container .product-desc {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
display: flex;
justify-content: left;
align-items: center;
color: #fff;
background-color: rgba(0, 0, 0, 0.6);
text-align: right;
padding: 14em 0.4em 0.2em;
-webkit-transform: translateY(101%);
transform: translateY(101%);
transition: -webkit-transform 0.8s ease-in-out;
transition: transform 0.8s ease-in-out;
transition: transform 0.8s ease-in-out, -webkit-transform 0.8s ease-in-out;
}
.client-container:hover .product-desc {
-webkit-transform: translateY(0);
transform: translateY(0);
}
.client-container .product-desc2 {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
display: flex;
justify-content: left;
align-items: center;
color: #fff;
text-align: right;
padding: 17em 0.4em 0.2em;
-webkit-transform: translateY(101%);
transform: translateY(101%);
transition: -webkit-transform 1s ease-in-out;
transition: transform 1s ease-in-out;
transition: transform 1s ease-in-out, -webkit-transform 1s ease-in-out;
}
.client-container:hover .product-desc2 {
-webkit-transform: translateY(0);
transform: translateY(0);
}
.brand-img {
display: block;
max-width: 100%;
height: auto;
transform: scale(1);
-ms-transform: scale(1);
-moz-transform: scale(1);
-webkit-transform: scale(1);
-o-transform: scale(1);
-webkit-transition: all 1.5s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
transition: all 1s ease;
}
.clients:hover .brand-img {
cursor: pointer;
transform: scale(1.5);
-ms-transform: scale(1.5);
-moz-transform: scale(1.5);
-webkit-transform: scale(1.2);
-o-transform: scale(1.5);
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<div class="clients BRANDING col-6 col-md-4 col-lg-3 col-lg-3">
<a href="#">
<figure class="client-container">
<img class="img-fluid brand-img" src="https://www.wrappixel.com/demos/ui-kit/wrapkit/assets/images/team/t3.jpg" alt="Logo">
<figcaption class="product-desc">
<P>paragraphparagraphparagraph</P>
</figcaption>
<figcaption class="product-desc2">
<h4>text</h4>
</figcaption>
</figure>
</a>
</div>
You could add a pseudo to the container, in that way the background "is there" and does its job of fading in when needed. That way the text is its own entity and you are free to style both just the way you want it. I added
.client-container::after
.client-container:hover::after
and removed the background-color on the first fig caption.
.clients {
position: relative;
}
.client-container {
position: relative;
width: 100%;
overflow: hidden;
}
.client-container::after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,.5);
opacity: 0;
visibility: hidden;
z-index: 0;
}
.client-container:hover::after {
opacity: 1;
visibility: visible;
transition: opacity 350ms;
}
.product-desc {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
display: flex;
justify-content: left;
align-items: center;
color: #fff;
text-align: right;
padding: 14em 0.4em 0.2em;
-webkit-transform: translateY(101%);
transform: translateY(101%);
transition: -webkit-transform 0.8s ease-in-out;
transition: transform 0.8s ease-in-out;
transition: transform 0.8s ease-in-out, -webkit-transform 0.8s ease-in-out;
z-index: 1;
}
.client-container:hover .product-desc {
-webkit-transform: translateY(0);
transform: translateY(0);
}
.product-desc2 {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
display: flex;
justify-content: left;
align-items: center;
color: #fff;
text-align: right;
padding: 17em 0.4em 0.2em;
-webkit-transform: translateY(101%);
transform: translateY(101%);
transition: -webkit-transform 1s ease-in-out;
transition: transform 1s ease-in-out;
transition: transform 1s ease-in-out, -webkit-transform 1s ease-in-out;
z-index: 1;
}
.client-container:hover .product-desc2 {
-webkit-transform: translateY(0);
transform: translateY(0);
}
.brand-img {
display: block;
max-width: 100%;
height: auto;
transform: scale(1);
-ms-transform: scale(1);
-moz-transform: scale(1);
-webkit-transform: scale(1);
-o-transform: scale(1);
-webkit-transition: all 1.5s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
transition: all 1s ease;
}
.clients:hover .brand-img {
cursor: pointer;
transform: scale(1.5);
-ms-transform: scale(1.5);
-moz-transform: scale(1.5);
-webkit-transform: scale(1.2);
-o-transform: scale(1.5);
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<div class="clients BRANDING col-6 col-md-4 col-lg-3 col-lg-3">
<a href="#">
<figure class="client-container">
<img class="img-fluid brand-img" src="https://www.wrappixel.com/demos/ui-kit/wrapkit/assets/images/team/t3.jpg" alt="Logo">
<figcaption class="product-desc">
<P>paragraphparagraphparagraph</P>
</figcaption>
<figcaption class="product-desc2">
<h4>text</h4>
</figcaption>
</figure>
</a>
</div>
I'm having some trouble understanding what it is you're trying to accomplish. What I think you want is that when a client hovers over the image that there is a small zoom and that some text comes slide-upwards. But you don't want them to see the overlay right?
If that's the case just keep your code the same but change background-color: rgba(0, 0, 0, 0.6);to background-color: transparent;.
I'm using this image zoom transition when i hover over an image. It's seems to work perfectly sometimes and sometimes it moves a little bit after zooming. I just can't figure out why..
Can anyone help me out why this happens
header {
width: 65.277777777777778%;
max-width: 1400px;
margin: 0 auto;
overflow: auto;
margin-bottom: 6%;
}
.container {
position: relative;
overflow: hidden;
/* height: 200px;
width: 200px; */
width: 100%;
}
.container img {
position: relative;
height: 100%;
width: 100%;
-webkit-transform: scale(1);
transform: scale(1);
-webkit-transition: transform;
transition: transform;
-webkit-transition-duration: 1s;
transition-duration: 1s;
display: flex;
}
.container:hover img {
-webkit-transform: scale(1.5);
transform: scale(1.5);
-webkit-transition: transform;
transition: transform;
-webkit-transition-duration: 1s;
transition-duration: 1s;
}
<header>
<div class="container">
<img src="https://pixabay.com/static/uploads/photo/2016/08/11/08/43/potatoes-1585060__340.jpg" alt="" />
</div>
</header>
Give this a try and see if it's more consistent for you. It works well for me, and I haven't noticed any issues in the months it's been implemented:
.container img {
-webkit-transition: all 1s ease-in-out;
-moz-transition: all 1s ease-in-out;
-ms-transition: all 1s ease-in-out;
-o-transition: all 1s ease-in-out;
transition: all 1s ease-in-out;
}
.container img:hover {
-webkit-transform: scale(1.5);
-moz-transform: scale(1.5);
-ms-transform: scale(1.5);
-o-transform: scale(1.5);
transform: scale(1.5);
}
See if this does the trick, if it's something you're interested in. Either way, let me know!
I am trying to rotate the icons on hover over. It doesn't seem to be working for me. The transition effect works fine. I wonder if I am using wrong tags for applying the rotation. Here is the code:
#import 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css';
#import 'https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css';
.list-icon-wrapper {
text-align: center;
}
.aticon i {
border-radius: 50%;
background: #5e8cfa;
width: 160px;
height: 160px;
text-align: center;
line-height: 100px;
vertical-align: middle;
padding: 30px;
color: #fff;
font-size: 60px;
}
.icon-wrapper:hover i {
background: #fff;
color: #5e8cfa;
border: 1px solid #5e8cfa;
transition: all 0.6s ease 0s;
-webkit-transition: all 0.6s ease 0s;
-moz-transition: all 0.6s ease 0s;
-ms-transition: all 0.6s ease 0s;
-o-transition: all 0.6s ease 0s;
display: inline-block;
}
.aticon:hover .fa {
transform: rotate(360deg);
-webkit-transform: rotate(360deg);
-o-transform: rotate(360deg);
-ms-transform: rotate(360deg);
-moz-transform: rotate(360deg);
}
.list-icon-wrapper .icon-wrapper p {
padding: 0 5px;
font-weight: 500;
font-size: 18px;
margin-top: 15px;
color: #000;
text-align: center;
display: inline-block;
}
<div class="list-icon-wrapper">
<div class="col-md-4">
<div class="icon-wrapper">
<span class="aticon">
<i class="fa fa-magnet"></i>
</span>
<p>Magnet</p>
</div>
</div>
<div class="col-md-4">
<div class="icon-wrapper">
<span class="aticon">
<i class="fa fa-clock-o"></i>
</span>
<p>Clock</p>
</div>
</div>
</div>
FontAwesome actually renders the icon on the :before pseudo-element rather than as a background image. I think all you need to do is target that rather than the .fa element. This should get you started.
.icon-wrapper:hover .fa::before {
background: #fff;
color: #5e8cfa;
border: 1px solid #5e8cfa;
transition: all 0.6s ease 0s;
-webkit-transition: all 0.6s ease 0s;
-moz-transition: all 0.6s ease 0s;
-ms-transition: all 0.6s ease 0s;
-o-transition: all 0.6s ease 0s;
display: inline-block;
}
.aticon:hover .fa::before {
transform-origin: center;
-ms-transform-origin: center;
-webkit-transform-origin: center;
transform: rotate(360deg);
-webkit-transform: rotate(360deg);
-o-transform: rotate(360deg);
-ms-transform: rotate(360deg);
-moz-transform: rotate(360deg);
}
I'm making a 3d box so I need most elements absolutely positioned. Front side is img, side is an empty div at the moment. Third div is a caption div, over the image with opacity of 0. I made simple hover effect to change this opacity to 1, it's working fine in FF, but not in Chrome.
I've seen that there are some bugs when using hover on absolute positioned elements in Chrome, but as I've understood, those occur only on elements with z-index, maybe I'm mistaken. Anyhow, here's the box code, I could really use some help figuring this one out, as I'm not able to pinpoint the problem Chrome is having.
HTML:
<div class="image-wrap">
<div class="image">
<img src="img/unyield.jpg" class="image-front">
<div class="image-caption">
<span class="caption-content">Unyielding sense</span><br/>
<span class="caption-one">cover artwork</span><br/>
<span class="read-more">INFO</div>
<div class="image-side"></div>
</div>
</div>
CSS BOX:
.image-wrap {
position: absolute;
top: 50%;
left: 5%;
margin-top: -225px;
width: 360px;
height: 550px;
perspective: 1000px;
-ms-perspective: 1000px;
-moz-perspective: 1000px;
-webkit-perspective: 1000px;
-o-perspective: 1000px;
}
.image {
position: absolute;
width: 360px;
height: 550px;
transform-style: preserve-3d;
-ms-transform-style: preserve-3d;
-moz-transform-style: preserve-3d;
-webkit-transform-style: preserve-3d;
-o-transform-style: preserve-3d;
transform: translateZ(-130px);
-ms-transform: translateZ(-130px);
-moz-transform: translateZ(-130px);
-webkit-transform: translateZ(-130px);
-o-transform: translateZ(-130px);
transition: all 1s ease;
-ms-transition: all 1s ease;
-moz-transition: all 1s ease;
-webkit-transition: all 1s ease;
-o-transition: all 1s ease;
}
.image-front, .image-side {
position: absolute;
width: 360px;
height: 550px;
backface-visibility: hidden;
-webkit-backface-visibility: hidden;
}
.image-front {
transform: translateZ(180px);
-ms-transform: translateZ(180px);
-moz-transform: translateZ(180px);
-webkit-transform: translateZ(180px);
-o-transform: translateZ(180px);
}
.image-side {
transform: rotateY(90deg) translateZ(180px);
-ms-transform: rotateY(90deg) translateZ(180px);
-moz-transform: rotateY(90deg) translateZ(180px);
-webkit-transform: rotateY(90deg) translateZ(180px);
-o-transform: rotateY(90deg) translateZ(180px);
border: 1px solid #B8B5B5;
background-color: green;
}
And the problematic caption CSS:
.image-caption {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 30%;
opacity: 0;
background-color: black;
color: white;
text-align: center;
padding-top: 25px;
transition: all 0.3s ease;
-ms-transition: all 0.3s ease;
-moz-transition: all 0.3s ease;
-webkit-transition: all 0.3s ease;
-o-transition: all 0.3s ease;
}
.image:hover .image-caption{
opacity: 0.8;
}
this is giving problems px use deg
.image-front {
transform: translateZ(180px);
-ms-transform: translateZ(180px);
-moz-transform: translateZ(180px);
-webkit-transform: translateZ(180px);
-o-transform: translateZ(180px);
}
see
stackoverflow.com/questions/hardware-acceleration-in-css3
and css-performance-relative-to-translatez0
I am having a problem with given below code
This is my stylesheet
.h_w:hover img{
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
-ms-transform: scale(1.1);
-o-transform: scale(1.1);
transform: scale(1.1);
-webkit-transition: 5s all;
-moz-transition: 5s all;
-o-transition: 5s all;
-ms-transition: 5s all;
transition: 5s all;
}
.h_w{ border-radius:200px;
-moz-border-radius: 200px;
-ms-border-radius: 200px;
-o-border-radius: 200px;
-webkit-border-radius: 200px;
height: 287px;
overflow: hidden;
position: relative;
width: 287px;
background-color: #FFFFFF;
}
.opacity-0.5{opacity:0.2;}
.circle_background{
background:url(../images/circle-bg.png) no-repeat;
height:100%;
width:100%;
position:absolute;
font-size:15px;
opacity:1 !important;
top: 286px;
}
.h_w:hover .circle_background{
transition:1s all;
-moz-transition:1s all;
-ms-transition:1s all;
-o-transition:1s all;
-webkit-transition:1s all;
top:0px;
z-index:1000px;
}
And this is my HTML
<body style="background-color: #000000;">
<div class="h_w">
<span><img src="images/projects/circles/background.png" alt="flick the switch" /></span>
</div>
</body>
This code is working fine in Mozilla firefox but in chrome it is not working when zooming it is going outside the circle.
Any help will be appreciated.
Look here for your answer: --->X<---
PS: you must add -webkit-mask-image: -webkit-radial-gradient(circle, white, black); to your img's parent-div styles.
Hope it helps.
Use this code it will work .
.h_w:hover img{
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
-ms-transform: scale(1.1);
-o-transform: scale(1.1);
transform: scale(1.1);
-webkit-transition: 5s img ;
-moz-transition: 5s img ;
-o-transition: 5s img ;
-ms-transition: 5s img ;
transition: 5s img ;
}
here above you can see that .h_w:hover img rule uses transtion property.
In transtion property I use img because You would like to create a motion on "img" not "all" property
So use "img" instead of "all".
Hope the answer!