When hover, I would like to translate an icon but CSS is not be effectible to it.
#humberger {
position: relative;
height: 24px;
width: 24px;
display: inline-block;
box-sizing: border-box;
}
#humberger div {
position: absolute;
left: 0;
height: 4px;
width: 24px;
background-color: #444;
border-radius: 2px;
box-sizing: border-box;
}
#humberger div:nth-of-type(1) {
top: 0;
}
#humberger div:nth-of-type(2) {
top: 10px;
}
#humberger div:nth-of-type(3) {
bottom: 0;
}
#humberger:hover {
div:nth-of-type(1) {
transform: rotate(20deg);
}
div:nth-of-type(2) {
transform: translateX(100px);
background: rgba(255, 255, 255, 0);
}
div:nth-of-type(3) {
transform: rotate(-20deg);
}
}
<div id="humberger">
<div onclick='openNav()'></div>
<div onclick='openNav()'></div>
<div onclick='openNav()'></div>
</div>
<span class='icon-title'>Open</span>
I am expecting the translation like below.
If someone gave me any knowledge to solve this, I would be very happy.
I think your CSS notation is not valid.
Try this structure instead:
#humberger:hover > div:nth-of-type(1){
transform: rotate(20deg);
cursor: pointer;
}
(tested and works)
Plz try this code..
css
#humberger div{
position: absolute;
left:0;
height:4px;
width: 24px;
background-color: #444;
border-radius: 2px;
box-sizing: border-box;
transition: 0.5s all ease 0s;
}
#humberger:hover div {
transition: 0.5s all ease 0s;
}
#humberger div:nth-of-type(1){
top:0;
}
#humberger div:nth-of-type(2) {
top: 10px;
}
#humberger div:nth-of-type(3) {
bottom:0;
}
#humberger:hover div:nth-of-type(1){
transform: rotate(45deg);
top: 10px;
}
#humberger:hover div:nth-of-type(2){
background: rgba(255, 255, 255, 0);
}
#humberger:hover div:nth-of-type(3){
transform: rotate(-45deg);
bottom: 10px;
}
Add transition time & transition-origin and adjust the degree of rotation.
#humberger div{
position: absolute;
left:0;
height:4px;
width: 24px;
background-color: #444;
border-radius: 2px;
box-sizing: border-box;
transition: .2s; /*Add transition time*/
transform-origin: 100% center; /*Add transform origin*/
}
#humberger:hover{
div:nth-of-type(1){
transform: rotate(-55deg); /*Adjust angle*/
}
div:nth-of-type(2){
transform: translateX(100px);
background: rgba(255, 255, 255, 0);
}
div:nth-of-type(3){
transform: rotate(55deg); /*Adjust angle*/
}
}
kindly follow the SASS Structure.
this is the SASS Code for your structure:
#humberger {
position: relative;
height: 24px;
width: 24px;
display: inline-block;
box-sizing: border-box;
div{
position: absolute;
left:0;
height:4px;
width: 24px;
background-color: #444;
border-radius: 2px;
box-sizing: border-box;
transition: all 0.3s;
&:nth-of-type(1){
top:0;
}
&:nth-of-type(2) {
top: 10px;
}
&:nth-of-type(3) {
bottom:0;
}
}
&:hover{
div{
&:nth-of-type(1){
transform: rotate(45deg);
top: 0;
bottom: 0;
margin: auto;
}
&:nth-of-type(2){
transform: translateX(100px);
background: rgba(255, 255, 255, 0);
}
&:nth-of-type(3){
transform: rotate(-45deg);
top: 0;
bottom: 0;
margin: auto;
}
}
}
}
this is the code snippet with normal css.
#humberger {
position: relative;
height: 24px;
width: 24px;
display: inline-block;
box-sizing: border-box;
}
#humberger div {
position: absolute;
left: 0;
height: 4px;
width: 24px;
background-color: #444;
border-radius: 2px;
box-sizing: border-box;
-webkit-transition: all 0.3s;
transition: all 0.3s;
}
#humberger div:nth-of-type(1) {
top: 0;
}
#humberger div:nth-of-type(2) {
top: 10px;
}
#humberger div:nth-of-type(3) {
bottom: 0;
}
#humberger:hover div:nth-of-type(1) {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
top: 0;
bottom: 0;
margin: auto;
}
#humberger:hover div:nth-of-type(2) {
-webkit-transform: translateX(100px);
transform: translateX(100px);
background: rgba(255, 255, 255, 0);
}
#humberger:hover div:nth-of-type(3) {
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
top: 0;
bottom: 0;
margin: auto;
}
<div id="humberger">
<div onclick='openNav()'></div>
<div onclick='openNav()'></div>
<div onclick='openNav()'></div>
</div>
<span class='icon-title'>Open</span>
the above SASS code is work same like the Snippet.
I hope this answer will helpful to you.
Thank You...
Related
I am making this rounded scroll down button with an arrow inside. On hover I wanted to apply an animation that makes the arrow go from above to below the rounded div, and it should be hidden when outside the div.
I tried using overflow: hidden but for some reason it doesn't work. Does anyone has a solution for this please?
Codepen: https://codepen.io/RaphaelleD/pen/vYpqxpm
#keyframes tipUp {
0% {
transform: translateY(-10px) rotateZ(225deg);
}
100% {
transform: translateY(100px) rotateZ(225deg);
}
}
#keyframes lineUp {
0% {
transform: translateY(-10px);
}
100% {
transform: translateY(100px);
}
}
.scrolldown {
position: relative;
margin: 0 auto;
}
.scrolldown p {
font-size: 1rem;
font-weight: 600;
padding-bottom: 0.8rem;
text-align: center;
}
.scrolldown__arrow {
width: 6rem;
height: 6rem;
border: 6px solid black;
border-radius: 50%;
margin: 0 auto;
overflow: hidden;
}
.scrolldown__arrow:before {
position: absolute;
display: inline-block;
content: "";
background: black;
width: 10px;
height: 45px;
top: 50%;
left: 50%;
margin-top: -50px;
margin-left: -5px;
transform: translateY(50px);
}
.scrolldown__arrow:after {
position: absolute;
display: inline-block;
content: "";
width: 22px;
height: 22px;
color: black;
border-top: 9px solid;
border-left: 9px solid;
transform: rotateZ(45deg);
top: 50%;
left: 50%;
margin-top: -30px;
margin-left: -15.5px;
transform: translateY(50px) rotateZ(225deg);
}
.scrolldown__arrow:hover:before {
animation: lineUp 1s cubic-bezier(0, 0.6, 1, 0.4) infinite 0.5s;
}
.scrolldown__arrow:hover:after {
animation: tipUp 1s cubic-bezier(0, 0.6, 1, 0.4) infinite 0.5s;
}
}
}
<body>
<div class="scrolldown">
<p>SCROLL DOWN</p>
<div class="scrolldown__arrow"></div>
</div>
</body>
I believe this is because of position: absolute, which takes the arrow out of the normal flow. In order to kinda preserve it in the flow, I've added position: relative to the arrow parent, and had to adjust top position as well, seems to work as expected:
#keyframes tipUp {
0% {
transform: translateY(-10px) rotateZ(225deg);
}
100% {
transform: translateY(100px) rotateZ(225deg);
}
}
#keyframes lineUp {
0% {
transform: translateY(-10px);
}
100% {
transform: translateY(100px);
}
}
.scrolldown {
position: relative;
margin: 0 auto;
}
.scrolldown p {
font-size: 1rem;
font-weight: 600;
padding-bottom: 0.8rem;
text-align: center;
}
.scrolldown__arrow {
width: 6rem;
height: 6rem;
border: 6px solid black;
border-radius: 50%;
margin: 0 auto;
overflow: hidden;
position: relative;
}
.scrolldown__arrow:before {
position: absolute;
display: inline-block;
content: "";
background: black;
width: 10px;
height: 45px;
top: 25%;
left: 50%;
margin-top: -50px;
margin-left: -5px;
transform: translateY(50px);
}
.scrolldown__arrow:after {
position: absolute;
display: inline-block;
content: "";
width: 22px;
height: 22px;
color: black;
border-top: 9px solid;
border-left: 9px solid;
transform: rotateZ(45deg);
top: 25%;
left: 50%;
margin-top: -30px;
margin-left: -15.5px;
transform: translateY(50px) rotateZ(225deg);
}
.scrolldown__arrow:hover:before {
animation: lineUp 1s cubic-bezier(0, 0.6, 1, 0.4) infinite 0.5s;
}
.scrolldown__arrow:hover:after {
animation: tipUp 1s cubic-bezier(0, 0.6, 1, 0.4) infinite 0.5s;
}
}
}
<body>
<div class="scrolldown">
<p>SCROLL DOWN</p>
<div class="scrolldown__arrow"></div>
</div>
</body>
I have a div, and within it is an image that should work as a link to another page. There is some text laid over it. located here https://wearehomefolks.com/index.php/home/
I have taken this from somewhere else on the web, I may have modified it a little.
I just want the image to link out to the other internal pages. And keep the hover effect.
When I hover over the images of which there are 5, there is no linking action. What is going wrong here please?
<div class="hvrbox">
<a href="https://wearehomefolks.com/index.php/product-category/home-collection/">
<img src="https://wearehomefolks.com/wp-content/uploads/2021/07/Homefolks_Instruments_brass_edition_homefolks_homepage.jpg" alt="Mountains" class="hvrbox-layer_bottom">
</a>
<div class="hvrbox-layer_top">
<div class="hvrbox-text">HOME COLLECTION
</div>
</div>
</div>
css:
.hvrbox,
.hvrbox * {
box-sizing: border-box;
}
.hvrbox {
position: relative;
/*display: inline-block;*/
overflow: hidden;
max-width: 100%;
height: auto;
}
.hvrbox img {
max-width: 100%;
width:100%;
}
.hvrbox .hvrbox-layer_bottom {
display: block;
width: 100%;
}
.hvrbox .hvrbox-layer_top {
opacity: 0;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.4);
color: #fff;
/*padding: 15px;*/
-moz-transition: all 0.4s ease-in-out 0s;
-webkit-transition: all 0.4s ease-in-out 0s;
-ms-transition: all 0.4s ease-in-out 0s;
transition: all 0.4s ease-in-out 0s;
}
.hvrbox:hover .hvrbox-layer_top,
.hvrbox.active .hvrbox-layer_top {
opacity: 1;
}
.hvrbox .hvrbox-text {
text-align: center;
font-size: 4rem;
display: inline-block;
position: absolute;
line-height:4.5rem;
top: 50%;
left: 50%;
-moz-transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.hvrbox .hvrbox-text_mobile {
font-size: 15px;
border-top: 1px solid rgb(179, 179, 179); /* for old browsers */
border-top: 1px solid rgba(179, 179, 179, 0.7);
margin-top: 5px;
padding-top: 2px;
display: none;
}
.hvrbox.active .hvrbox-text_mobile {
display: block;
}
Thanks
You should add pointer-events: none to the overlay (i.e. the CSS rule for .hvrbox .hvrbox-layer_top). That way the click can "go through it" to the linked image to trigger the link:
.hvrbox,
.hvrbox * {
box-sizing: border-box;
}
.hvrbox {
position: relative;
/*display: inline-block;*/
overflow: hidden;
max-width: 100%;
height: auto;
}
.hvrbox img {
max-width: 100%;
width:100%;
}
.hvrbox .hvrbox-layer_bottom {
display: block;
width: 100%;
}
.hvrbox .hvrbox-layer_top {
opacity: 0;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.4);
color: #fff;
/*padding: 15px;*/
-moz-transition: all 0.4s ease-in-out 0s;
-webkit-transition: all 0.4s ease-in-out 0s;
-ms-transition: all 0.4s ease-in-out 0s;
transition: all 0.4s ease-in-out 0s;
pointer-events:none;
}
.hvrbox:hover .hvrbox-layer_top,
.hvrbox.active .hvrbox-layer_top {
opacity: 1;
}
.hvrbox .hvrbox-text {
text-align: center;
font-size: 4rem;
display: inline-block;
position: absolute;
line-height:4.5rem;
top: 50%;
left: 50%;
-moz-transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.hvrbox .hvrbox-text_mobile {
font-size: 15px;
border-top: 1px solid rgb(179, 179, 179); /* for old browsers */
border-top: 1px solid rgba(179, 179, 179, 0.7);
margin-top: 5px;
padding-top: 2px;
display: none;
}
.hvrbox.active .hvrbox-text_mobile {
display: block;
}
<div class="hvrbox">
<a href="https://wearehomefolks.com/index.php/product-category/home-collection/">
<img src="https://wearehomefolks.com/wp-content/uploads/2021/07/Homefolks_Instruments_brass_edition_homefolks_homepage.jpg" alt="Mountains" class="hvrbox-layer_bottom">
</a>
<div class="hvrbox-layer_top">
<div class="hvrbox-text">HOME COLLECTION
</div>
</div>
</div>
body{
margin: 0;
padding: 0;
background-color: #073146;
}
.box{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
width: 350px;
height: 180px;
background-color: #001e2d;
box-sizing: border-box;
overflow: hidden;
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
border: 2px solid rgba(0, 0, 0, 0.5);
}
.box::before{
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background-color: rgba(255,255,255,0.1);
transition: 0.5s;
pointer-events: none;
}
.box:hover:before{
left: -50%;
transform: skewX(-5deg);
}
/* this controls the text inside the box */
.box .content{
position: absolute;
top: 15px;
left: 15px;
right: 15px;
bottom: 15px;
border: 2px solid #ffeb3b;
padding: 30px;
text-align: center;
box-shadow: 0 15px 10px rgba(0, 0, 0, 0.5);
}
.box .content h1{
color: white;
font-size: 30px;
margin: 0 0 10px;
padding: 0;
}
.box .content p{
color: white;
}
.box span{
position: absolute;
top: 0;
left: 0;
width: 149%;
height: 100%;
display: block;
box-sizing: border-box;
}
.box span:nth-child(1){
transform: rotate(0deg);
}
.box span:nth-child(2){
transform: rotate(90deg);
}
.box span:nth-child(3){
transform: rotate(180deg);
}
.box span:nth-child(4){
transform: rotate(270deg);
}
/* setting up one line */
.box span:before{
content: '';
position: absolute;
width: 100%;
height: 2px;
background-color: #0093ff;
animation: animate 4s linear infinite;
}
#keyframes animate {
0%{
transform: scaleX(0);
transform-origin: left;
}
50%{
transform: scaleX(1);
transform-origin: left;
}
50.1%{
transform: scaleX(1);
transform-origin: right;
}
100%{
transform: scaleX(0);
transform-origin: right;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="main.css">
</head>
<body>
<div class="box">
<span></span>
<span></span>
<span></span>
<span></span>
<div class="content">
<h1>Some heaading</h1>
<p>Three border is going perfect but the fourth border is messing up.</p>
</div>
</div>
</body>
</html>
I created this CSS but the problem with my CSS is I am not able to get all four borders on end. I am managed to get 3 borders but the fourth border does not seem to fit properly. I was wondering if someone can guide me on how to arrange all four borders blue color at the end of the card. Could some one please guide or help to get proper animation. I would really appreciate some help on this.
Thank you in advance
Use two animation effects, Because the width and height are different, changing the Angle of the animation line is not on the edge.
body{
margin: 0;
padding: 0;
background-color: #073146;
}
.box{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
width: 350px;
height: 180px;
background-color: #001e2d;
box-sizing: border-box;
overflow: hidden;
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
border: 2px solid rgba(0, 0, 0, 0.5);
}
.box::before{
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background-color: rgba(255,255,255,0.1);
transition: 0.5s;
pointer-events: none;
}
.box:hover:before{
left: -50%;
transform: skewX(-5deg);
}
/* this controls the text inside the box */
.box .content{
position: absolute;
top: 15px;
left: 15px;
right: 15px;
bottom: 15px;
border: 2px solid #ffeb3b;
padding: 30px;
text-align: center;
box-shadow: 0 15px 10px rgba(0, 0, 0, 0.5);
}
.box .content h1{
color: white;
font-size: 30px;
margin: 0 0 10px;
padding: 0;
}
.box .content p{
color: white;
}
.box span{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: block;
box-sizing: border-box;
}
.box span:nth-child(3){
transform: rotate(180deg);
}
.box span:nth-child(4){
transform: rotate(180deg);
}
/* setting up one line */
.box span:nth-child(odd):before{
content: '';
position: absolute;
width: 100%;
height: 2px;
background-color: #0093ff;
animation: animate 4s linear infinite;
}
.box span:nth-child(even):before{
content: '';
position: absolute;
height: 100%;
width: 2px;
background-color: #0093ff;
animation: animate2 4s linear infinite;
}
#keyframes animate {
0%{
transform: scaleX(0);
transform-origin: left;
}
50%{
transform: scaleX(1);
transform-origin: left;
}
50.1%{
transform: scaleX(1);
transform-origin: right;
}
100%{
transform: scaleX(0);
transform-origin: right;
}
}
#keyframes animate2 {
0%{
transform: scaleY(0);
transform-origin: bottom;
}
50%{
transform: scaleY(1);
transform-origin: bottom;
}
50.1%{
transform: scaleY(1);
transform-origin: top;
}
100%{
transform: scaleY(0);
transform-origin: top;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="main.css">
</head>
<body>
<div class="box">
<span></span>
<span></span>
<span></span>
<span></span>
<div class="content">
<h1>Some heaading</h1>
<p>Three border is going perfect but the fourth border is messing up.</p>
</div>
</div>
</body>
</html>
.box span:nth-child(2){
transform: rotate(90deg);
right: -170px;
left: auto;
}.box span:nth-child(2){
transform: rotate(90deg);
right: -170px;
left: auto;
}
.box span:nth-child(3){
transform: rotate(180deg);
}
.box span:nth-child(4){
transform: rotate(270deg);
left: -170px;
}
I dont know if this is right or there is any other proper solution but this work for me. Thank you to the commentor to direct me in proper direction. I appreciate it
You need to set the width: property to the animation's full width underneath .box span, and then set its second and fourth nth-child's right: and left properties. Something like:
body {
margin: 0;
padding: 0;
background-color: #073146;
}
.box {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 350px;
height: 180px;
background-color: #001e2d;
box-sizing: border-box;
overflow: hidden;
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
border: 2px solid rgba(0, 0, 0, 0.5);
}
.box::before {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, 0.1);
transition: 0.5s;
pointer-events: none;
}
.box:hover:before {
left: -50%;
transform: skewX(-5deg);
}
/* this controls the text inside the box */
.box .content {
position: absolute;
top: 15px;
left: 15px;
right: 15px;
bottom: 15px;
border: 2px solid #ffeb3b;
padding: 30px;
text-align: center;
box-shadow: 0 15px 10px rgba(0, 0, 0, 0.5);
}
.box .content h1 {
color: white;
font-size: 30px;
margin: 0 0 10px;
padding: 0;
}
.box .content p {
color: white;
}
.box span {
position: absolute;
top: 0;
left: 0;
width: 350px;
height: 100%;
display: block;
box-sizing: border-box;
}
.box span:nth-child(1) {
transform: rotate(0deg);
}
.box span:nth-child(2) {
transform: rotate(90deg);
right: -87px;
left: auto;
}
.box span:nth-child(3) {
transform: rotate(180deg);
}
.box span:nth-child(4) {
transform: rotate(270deg);
left: -87px;
right: auto;
}
/* setting up one line */
.box span::before {
content: '';
position: absolute;
width: 100%;
height: 2px;
background-color: #0093ff;
animation: animate 4s linear infinite;
}
#keyframes animate {
0% {
transform: scaleX(0);
transform-origin: left;
}
50% {
transform: scaleX(1);
transform-origin: left;
}
50.1% {
transform: scaleX(1);
transform-origin: right;
}
100% {
transform: scaleX(0);
transform-origin: right;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="main.css">
</head>
<body>
<div class="box">
<span></span>
<span></span>
<span></span>
<span></span>
<div class="content">
<h1>Some heaading</h1>
<p>Three border is going perfect but the fourth border is messing up.</p>
</div>
</div>
</body>
</html>
Here is a simplified version where you will need few lines of code. The whole animation can be done using background without extra elements:
body {
margin: 0;
background-color: #073146;
}
.box {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 350px;
background:
linear-gradient(#0093ff 0 0) 0 0,
linear-gradient(#0093ff 0 0) 100% 0,
linear-gradient(#0093ff 0 0) 100% 100%,
linear-gradient(#0093ff 0 0) 0 100%;
background-size:100% 2px,2px 100%;
background-repeat:no-repeat;
background-color: #001e2d;
box-sizing: border-box;
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
border: 2px solid rgba(0, 0, 0, 0.5);
overflow:hidden;
animation:animate 2s linear infinite;
}
#keyframes animate{
from {
background-size:0% 2px,2px 0%;
background-position:0 0,100% 0,100% 100%,0 100%;
}
50% {
background-size:100% 2px,2px 100%;
background-position:0 0,100% 0,100% 100%,0 100%;
}
50.1% {
background-size:100% 2px,2px 100%;
background-position:100% 0,100% 100%,0 100%,0 0;
}
100% {
background-size:0% 2px,2px 0%;
background-position:100% 0,100% 100%,0 100%,0 0;
}
}
.box::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 0%;
height: 100%;
background-color: rgba(255, 255, 255, 0.1);
transition: 0.5s;
pointer-events: none;
transform-origin:top;
}
.box:hover:before {
width:50%;
transform: skewX(-5deg);
}
.box .content {
margin:15px;
border: 2px solid #ffeb3b;
padding: 30px;
text-align: center;
color: white;
box-shadow: 0 15px 10px rgba(0, 0, 0, 0.5);
}
.box .content h1 {
font-size: 30px;
margin: 0 0 10px;
}
<div class="box">
<div class="content">
<h1>Some heaading</h1>
<p>Three border is going perfect but the fourth border is messing up.</p>
</div>
</div>
Related question with a similar effect: Drawing border colors during a CSS transition
I have two different containers one contains a play button with animation effects and the other is just a wave animation.
I can't find a solution to make them one by putting the play button over the wave animation so that we have a play button with a wave effect outside.
/*Video Player*/
.videoContainer {
padding-top: 10rem;
}
.video-play-button {
position: relative;
z-index: 10;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
box-sizing: content-box;
display: block;
width: 32px;
height: 44px;
/* background: #fa183d; */
border-radius: 50%;
padding: 18px 20px 18px 28px;
-webkit-box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.75);
box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.75);
}
.video-play-button:before {
content: "";
position: absolute;
z-index: 0;
left: 50%;
top: 50%;
transform: translateX(-50%) translateY(-50%);
display: block;
width: 80px;
height: 80px;
background: #ba1f24;
border-radius: 50%;
}
.video-play-button:after {
content: "";
position: absolute;
z-index: 1;
left: 50%;
top: 50%;
transform: translateX(-50%) translateY(-50%);
display: block;
width: 80px;
height: 80px;
background: #fa183d;
border-radius: 50%;
transition: all 200ms;
}
.video-play-button:hover:after {
background-color: darken(#fa183d, 10%);
}
.video-play-button img {
position: relative;
z-index: 3;
max-width: 100%;
width: auto;
height: auto;
}
.video-play-button span {
display: block;
position: relative;
z-index: 3;
width: 0;
height: 0;
border-left: 32px solid #fff;
border-top: 22px solid transparent;
border-bottom: 22px solid transparent;
}
.video-overlay {
position: fixed;
width: 100%;
height: auto;
z-index: -1;
top: 0;
bottom: 0;
left: 0;
right: 10px;
background: rgba(0,0,0,0.80);
opacity: 0;
transition: all ease 500ms;
}
.video-overlay.open {
position: fixed;
top: 0;
left: 0;
z-index: 999;
opacity: 1;
}
.video-overlay-close {
position: relative;
z-index: 1000;
top:75px;
right: 75px;
font-size: 40px;
line-height: 1;
font-weight: 400;
color: #fff;
text-decoration: none;
cursor: pointer;
transition: all 200ms;
}
.video-overlay-close:hover {
color: #fa183d;
}
.video-overlay iframe {
position: absolute;
top: 54%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
width: 80%;
height: 80%;
box-shadow: 0 0 15px rgba(0,0,0,0.75);
}
/*=======================================================
VIDEO POP UP:
========================================================*/
.waves-block {
position: relative;
margin-top: 260px;
margin-bottom: 100px;
float: center;
width: 384px;
width: 24rem;
height: 384px;
height: 24rem;
left: 50%;
top: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
z-index: 1;
}
.waves-block .waves {
position: absolute;
width: 384px;
width: 24rem;
height: 384px;
height: 24rem;
background: rgb(178, 163, 214, 0.2);
opacity: 0;
border-radius: 320px;
-webkit-animation: waves 3s ease-in-out infinite;
animation: waves 3s ease-in-out infinite;
}
.waves-block .wave-1 {
-webkit-animation-delay: 0s;
animation-delay: 0s;
}
.waves-block .wave-2 {
-webkit-animation-delay: 1s;
animation-delay: 1s;
}
.waves-block .wave-3 {
-webkit-animation-delay: 2s;
animation-delay: 2s;
}
#keyframes waves {
0% {
-webkit-transform: scale(0.2, 0.2);
transform: scale(0.2, 0.2);
opacity: 0;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
}
50% {
opacity: 0.9;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=90)";
}
100% {
-webkit-transform: scale(0.9, 0.9);
transform: scale(0.9, 0.9);
opacity: 0;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
}
}
<section class="videoContainer">
<a id="play-video" class="video-play-button" href="#">
<span></span>
</a>
<div id="video-overlay" class="video-overlay">
<a class="video-overlay-close">×</a>
</div>
</section>
<div class="waves-block">
<div class="waves wave-1"></div>
<div class="waves wave-2"></div>
<div class="waves wave-3"></div>
</div>
I have tried to change the positions but because of the margins, it was a failure.
Any suggestions would be greatly appreciated.
add the wave to the play-video element
remove the margins from wave element
set wave element to position:absolute; instead of relative
/*Video Player*/
.videoContainer {
padding-top: 10rem;
}
.video-play-button {
position: relative;
z-index: 10;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
box-sizing: content-box;
display: block;
width: 32px;
height: 44px;
/* background: #fa183d; */
border-radius: 50%;
padding: 18px 20px 18px 28px;
-webkit-box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.75);
box-shadow: 0px 2px 5px 0px rgba(0,0,0,0.75);
}
.video-play-button:before {
content: "";
position: absolute;
z-index: 0;
left: 50%;
top: 50%;
transform: translateX(-50%) translateY(-50%);
display: block;
width: 80px;
height: 80px;
background: #ba1f24;
border-radius: 50%;
}
.video-play-button:after {
content: "";
position: absolute;
z-index: 1;
left: 50%;
top: 50%;
transform: translateX(-50%) translateY(-50%);
display: block;
width: 80px;
height: 80px;
background: #fa183d;
border-radius: 50%;
transition: all 200ms;
}
.video-play-button:hover:after {
background-color: darken(#fa183d, 10%);
}
.video-play-button img {
position: relative;
z-index: 3;
max-width: 100%;
width: auto;
height: auto;
}
.video-play-button span {
display: block;
position: relative;
z-index: 3;
width: 0;
height: 0;
border-left: 32px solid #fff;
border-top: 22px solid transparent;
border-bottom: 22px solid transparent;
}
.video-overlay {
position: fixed;
width: 100%;
height: auto;
z-index: -1;
top: 0;
bottom: 0;
left: 0;
right: 10px;
background: rgba(0,0,0,0.80);
opacity: 0;
transition: all ease 500ms;
}
.video-overlay.open {
position: fixed;
top: 0;
left: 0;
z-index: 999;
opacity: 1;
}
.video-overlay-close {
position: relative;
z-index: 1000;
top:75px;
right: 75px;
font-size: 40px;
line-height: 1;
font-weight: 400;
color: #fff;
text-decoration: none;
cursor: pointer;
transition: all 200ms;
}
.video-overlay-close:hover {
color: #fa183d;
}
.video-overlay iframe {
position: absolute;
top: 54%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
width: 80%;
height: 80%;
box-shadow: 0 0 15px rgba(0,0,0,0.75);
}
/*=======================================================
VIDEO POP UP:
========================================================*/
.waves-block {
position: absolute;
float: center;
width: 384px;
width: 24rem;
height: 384px;
height: 24rem;
left: 50%;
top: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
z-index: 1;
}
.waves-block .waves {
position: absolute;
width: 384px;
width: 24rem;
height: 384px;
height: 24rem;
background: rgb(178, 163, 214, 0.2);
opacity: 0;
border-radius: 320px;
-webkit-animation: waves 3s ease-in-out infinite;
animation: waves 3s ease-in-out infinite;
}
.waves-block .wave-1 {
-webkit-animation-delay: 0s;
animation-delay: 0s;
}
.waves-block .wave-2 {
-webkit-animation-delay: 1s;
animation-delay: 1s;
}
.waves-block .wave-3 {
-webkit-animation-delay: 2s;
animation-delay: 2s;
}
#keyframes waves {
0% {
-webkit-transform: scale(0.2, 0.2);
transform: scale(0.2, 0.2);
opacity: 0;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
}
50% {
opacity: 0.9;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=90)";
}
100% {
-webkit-transform: scale(0.9, 0.9);
transform: scale(0.9, 0.9);
opacity: 0;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
}
}
<section class="videoContainer">
<a id="play-video" class="video-play-button" href="#">
<span></span>
<div class="waves-block">
<div class="waves wave-1"></div>
<div class="waves wave-2"></div>
<div class="waves wave-3"></div>
</div>
</a>
<div id="video-overlay" class="video-overlay">
<a class="video-overlay-close">×</a>
</div>
</section>
Helo Guys!
I was trying to create a spinning hover effect with CSS3.
Just made a circle spinning effect. Check the jsFiddle here: http://jsfiddle.net/63yyeezn/26/
However what I want to do now is to create something tthat spins but this time its box type
just like this image:
So basically I want similar effect just like the jsFiddle I shown above however this time it must be box.
Really having a hard time figuring this out. Here's my CSS:
body {
background: #292929;
padding-left: 30px;
font-size: 12px;
}
.twist {
display: inline-block;
font-size: 45px;
line-height: 90px;
cursor: pointer;
margin: 20px;
width: 90px;
height: 90px;
border-radius: 50%;
text-align: center;
position: relative;
text-decoration: none;
z-index: 1;
color: #fff;
}
.twist:after {
pointer-events: none;
position: absolute;
width: 100%;
height: 100%;
border-radius: 50%;
content:'';
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
}
.twist:before {
speak: none;
font-size: 48px;
line-height: 90px;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
display: block;
-webkit-font-smoothing: antialiased;
}
.twist.demo-4 {
width: 92px;
height: 92px;
box-shadow: 0 0 0 4px rgba(255, 255, 255, 1);
}
.twist.demo-4:before {
line-height: 92px;
}
.twist.demo-4:after {
top: -4px;
left: -4px;
padding: 0;
z-index: 10;
border: 4px dashed #fff;
}
.twist.demo-4:hover {
box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
color: #fff;
}
.twist.demo-4:hover i {
color: #fff;
}
.twist.demo-4.spin:hover {
-webkit-transition: box-shadow 0.2s;
-moz-transition: box-shadow 0.2s;
transition: box-shadow 0.2s;
}
.twist.demo-4.spin:hover:after {
-webkit-animation: spinAround 9s linear infinite;
-moz-animation: spinAround 9s linear infinite;
animation: spinAround 9s linear infinite;
}
#-webkit-keyframes spinAround {
from {
-webkit-transform: rotate(0deg)
}
to {
-webkit-transform: rotate(360deg);
}
}
#-moz-keyframes spinAround {
from {
-moz-transform: rotate(0deg)
}
to {
-moz-transform: rotate(360deg);
}
}
#keyframes spinAround {
from {
transform: rotate(0deg)
}
to {
transform: rotate(360deg);
}
}
Hope you can help me with a jsFiddle file.
Thanks!
My answer won't fit exactly your example, but may interest you as it's a full-CSS3 solution, without HTML markup change. The animation won't be a rotation, but a translation.
Webkit version
.bordered {
overflow: hidden;
}
.bordered:before {
content: '';
position: absolute;
top: 5px; /* 5px: border width */
left: 5px;
right: 5px;
bottom: 5px;
background: white;
z-index: -1;
}
.bordered:after {
content: '';
position: absolute;
top: -50%;
left: -50%;
right: -50%;
bottom: -50%;
background: black;
z-index: -2;
}
.bordered:hover:after {
background: -webkit-linear-gradient(left, white 50%, black 50%); /* black: border color*/
background-size: 20px 100%; /* 20px: dash width */
-webkit-animation: borderAnimated 1s linear infinite;
}
#-webkit-keyframes borderAnimated {
from {
transform: rotate(45deg) translate(0, 0);
}
to {
transform: rotate(45deg) translate(20px, 0);
}
}
/* --- Style only--- */
.bordered {
width: 150px;
height: 150px;
line-height: 150px;
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
<div class="bordered">Lorem ipsum</div>
The trick is to have a stripped background in the :after pseudo-element, and a fake empty background in the :before element, which will work as a mask. When hovering your element, you just have to animate the :after pseudo-element to get something nice.
Credits: #vsynz
I don't think it can be possible only with static borders. Here is an alternative solution:
.rotating-dashed {
position: relative;
margin: 40px auto;
width: 90px;
height: 90px;
overflow: hidden;
color: #268;
}
.rotating-dashed .dashing {
display: block;
width: 100%;
height: 100%;
position: absolute;
}
.rotating-dashed .dashing:nth-of-type(2) {
-webkit-transform: rotate(90deg);
}
.rotating-dashed .dashing:nth-of-type(3) {
-webkit-transform: rotate(180deg);
}
.rotating-dashed .dashing:nth-of-type(4) {
-webkit-transform: rotate(270deg);
}
.rotating-dashed .dashing i {
display: block;
position: absolute;
left: 0;
top: 0;
width: 200%;
border-bottom: 5px solid
}
.rotating-dashed strong {
display: block;
width: 105%;
line-height: 90px;
text-align: center;
position: absolute;
}
.rotating-dashed:hover {
cursor: pointer;
}
.rotating-dashed:hover .dashing i {
-webkit-animation: slideDash 2.5s infinite linear;
border-bottom: 5px dashed
}
#-webkit-keyframes slideDash {
from {
-webkit-transform: translateX(-50%);
}
to {
-webkit-transform: translateX(0%);
}
}
<div class="rotating-dashed"> <span class="dashing"><i></i></span>
<span class="dashing"><i></i></span>
<span class="dashing"><i></i></span>
<span class="dashing"><i></i></span>
<strong>Demo</strong>
</div>