Why is the transform property not working - css

So I know that two transforms don't apply at the same time. But at hover, they can replace each other?! Following is the code for a button I am trying to make, but when I hover, the properties don't seem to work! Also, the down-arrow I am trying to insert in there is also not exactly at the center. So due to which I have to use padding to center it!
.btn__bg {
position: absolute;
display: inline-block;
opacity: 0;
top: 75%;
left: 50%;
transform: translate(-50%, -50%);
height: 60px;
width: 60px;
background-color: #000;
border-radius: 50%;
text-align: center;
animation: fadeInTop 1.2s forwards ease-out 1.5s;
transition: all .2s;
box-shadow: 0 4px 40px rgba(0,0,0,.3);
}
.btn__content {
font-size: 30px;
color: #fff;
font-weight: 100;
text-decoration: none;
line-height: normal;
}
.btn__down--text {
display: inline-block;
vertical-align: middle;
}
.btn__bg:hover {
transform: translate(-50%, -50%) scale(1.5);
}
.btn__bg:hover ~ .btn__down--text {
vertical-align: middle;
}
<div class="header__main--text">
<h1 class="header__heading--primary usr-res">welcome</h1>
<a href="#" class="btn btn__bg btn__content usr-res">
<span class="btn__down--text">&downarrow;</span>
</a>
</div>
Any help would be appreciated!

It's not really clear what you mean: The scaling works (?)
The vertical position of the arrow can be adjusted with a margin-top on the span which contains it.
.btn__bg {
position: absolute;
display: inline-block;
opacity: 1;
top: 75%;
left: 50%;
transform: translate(-50%, -50%);
height: 60px;
width: 60px;
background-color: white;
border-radius: 50%;
text-align: center;
animation: fadeInTop 1.2s forwards ease-out 1.5s;
transition: all .2s;
box-shadow: 0 4px 40px rgba(0,0,0,.3);
}
.btn__content {
font-size: 30px;
color: #000;
font-weight: 100;
text-decoration: none;
line-height: normal;
}
.btn__down--text {
display: inline-block;
margin-top:0.3em;
}
.btn__bg:hover {
transform: translate(-50%, -50%) scale(1.5);
}
.btn__bg:hover ~ .btn__down--text {
vertical-align: middle;
}
<div class="header__main--text">
<h1 class="header__heading--primary usr-res">welcome</h1>
<a href="#" class="btn btn__bg btn__content usr-res">
<span class="btn__down--text">&downarrow;</span>
</a>
</div>

Related

How to hover parent & have child respond to keyframe animation

I am trying to write code that mimics this animation as much as possible.
I have been going over keyframe animations & I think that they can be used to do what I need them to do.
I effectively want to have three things happen when the user hovers over the parent element. The first is the color
on the right side of the element will change dynamically (as in the picture & as in the example code), the
icon will animate into the picture & then the text will then animate.
I am new to programming & I am looking for some direction.
Example of finished product: https://imgur.com/a/bxV1V1B
DEMO
.wrapper {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
a {
display: block;
width: 200px;
height: 40px;
line-height: 40px;
font-size: 18px;
font-family: sans-serif;
text-decoration: none;
color: #333;
border: 2px solid #333;
letter-spacing: 2px;
text-align: center;
position: relative;
transition: all .35s;
}
a span {
position: relative;
z-index: 2;
}
a:after {
position: absolute;
content: "";
top: 0;
right: 0;
width: 0;
height: 100%;
background: green;
transition: all .35s;
}
a:hover:after {
width: 15%;
}
<div class="wrapper">
<span>Hover Me!</span>
</div>
Here you go. I made a CSS animation for you which will rotate and translate a new i that I have added into the HTML. I used font awesome for the check with the circle around it. Take a look:
.wrapper {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
a {
display: block;
width: 200px;
height: 40px;
line-height: 40px;
font-size: 18px;
font-family: sans-serif;
text-decoration: none;
color: #333;
border: 2px solid #333;
letter-spacing: 2px;
text-align: center;
position: relative;
transition: all .35s;
}
a span {
position: relative;
z-index: 2;
}
a:after {
position: absolute;
content: "";
top: 0;
right: 0;
width: 0;
height: 100%;
background: green;
transition: all .35s;
visibility: hidden;
}
a:hover:after {
width: 15%;
visibility: visible;
}
#check {
right: 2px;
top: 8px;
position: absolute;
display: none;
z-index: 3;
transition: right .35s;
}
a:hover #check {
animation:spin .35s linear;
display: block;
}
#keyframes spin {
0% {
transform: translate(25px) rotate(0deg);
}
100% {
transform: translate(0px) rotate(360deg);
}
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="wrapper">
<span>Hover Me!</span><i id="check"style="font-size:22px; color:lightgrey" class="fa fa-check-circle"></i>
</div>

Animation from top to bottom in CSS

I make my project in Bootstrap 4.
I have this code:
.back-to-top {
width: 36px;
height: 36px;
border-radius: 50%;
text-align: center;
border: 3px solid #c1c1c1;
justify-content: center;
padding-top: 5px;
position: fixed;
bottom: 25px;
right: 15px;
display: none;
z-index: 999;
transition: opacity .5s;
}
.back-to-top::before {
padding-top: 15px;
animation-name: animation-arrow;
animation-duration: 1.5s;
animation-iteration-count: infinite;
}
#keyframes animation-arrow {
0% {
padding-top: 0px
}
50% {
padding-top: 5px
}
100% {
padding-top: 10px
}
}
<a id="back-to-top" href="#" class="back-to-top" role="button"><img src="images/back.png" class="img-fluid"> </a>
I'd like to move the images / back.png up / down arrow.
(I would like the picture to move slightly up / down) - but it doesn't work
How can I repair it?
check this out:
.back-to-top {
width: 36px;
height: 36px;
border-radius: 50%;
text-align: center;
border: 3px solid #c1c1c1;
position: fixed;
bottom: 25px;
right: 15px;
z-index: 999;
transition: opacity .5s;
}
.back-to-top > i {
width: 15px;
height: 15px;
margin-top: 15px;
display: inline-block;
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pg0KPCEtLSBHZW5lcmF0b3I6IEFkb2JlIElsbHVzdHJhdG9yIDE5LjAuMCwgU1ZHIEV4cG9ydCBQbHVnLUluIC4gU1ZHIFZlcnNpb246IDYuMDAgQnVpbGQgMCkgIC0tPg0KPHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJDYXBhXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgNDkwLjY4OCA0OTAuNjg4IiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA0OTAuNjg4IDQ5MC42ODg7IiB4bWw6c3BhY2U9InByZXNl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+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjxnPg0KPC9nPg0KPGc+DQo8L2c+DQo8Zz4NCjwvZz4NCjwvc3ZnPg0K) no-repeat;
}
.bounce {
animation: bounce 2s infinite;
}
#keyframes bounce {
0% {
transform: translateY(-10px);
}
50% {
transform: translateY(0);
}
100% {
transform: translateY(-10px);
}
}
<a id="back-to-top" href="#" class="back-to-top" role="button">
<i class="arrow bounce"></i>
</a>

Maintain button hover effect when outside of button

Hovering over btn should trigger display: block; on btn2 (which it does), then maintain this hover effect when I move the mouse below and outside of btn until I am able to click btn2 (which it currently doesn't).
I thought I could do this by using margin on btn, but that didn't work.
body {
background-color: #673ab7;
font-size: 30px;
}
.btn {
margin-bottom: 50px;
text-align: center;
line-height: 100px;
position: absolute;
left: 50%;
width: 100px;
height: 100px;
background-color: #00bcd4;
border-radius: 100%;
transition: all .2s ease-in-out;
&:hover {
transform:scale(1.05,1.05)
}
}
.btn2 {
position: absolute;
top: 110px;
left: 50.5%;
text-align: center;
line-height: 55px;
border-radius: 50px;
display: none;
width: 50px;
height: 50px;
background-color: black;
transition: all .2s ease-in-out;
&:hover {
transform:scale(1.05,1.05)
}
}
.btn:hover +.btn2{
transition: all .2s ease-in-out;
display: block;
position: absolute;
transform: scale(1.05,1.05);
transform: translate(20px);
}
.icon {
color: white;
}
.icon2 {
color: white;
width: 26px;
line-height: 20px;
}
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<div class="container">
<i class="icon fa fa-link"></i>
<i class="icon2 fa fa-edit"></i>
</div>
Set your :hover css to the parent .container tag of both items so the hover rules are maintained when moving from one element to the next. This way you are maintaining the hover state when moving from child to child.
I also changed display:none; to visibility:hidden; and opacity:0|opacity:1 respectively. `display:none' isn't going to animate.
The animation time also allows for a short period of overlap (non :focus) when moving from one element to the other. With some keyframing you can make the move from one to the other a bit cleaner.
body {
background-color: #673ab7;
font-size: 30px;
}
.btn {
margin-bottom: 50px;
text-align: center;
line-height: 100px;
position: absolute;
left: 50%;
width: 100px;
height: 100px;
background-color: #00bcd4;
border-radius: 100%;
transition: all .2s ease-in-out;
&:hover {
transform:scale(1.05,1.05)
}
}
.btn2 {
position: absolute;
top: 110px;
left: 50.5%;
text-align: center;
line-height: 55px;
border-radius: 50px;
visibility:hidden;
opacity:0;
width: 50px;
height: 50px;
background-color: black;
transition: all .2s ease-in-out;
&:hover {
transform:scale(1.05,1.05)
}
}
.container:hover .btn +.btn2{
transition: all .2s ease-in-out;
visibility:visible;
opacity:1;
position: absolute;
transform: scale(1.05,1.05);
transform: translate(20px);
}
.icon {
color: white;
}
.icon2 {
color: white;
width: 26px;
line-height: 20px;
}
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<div class="container">
<i class="icon fa fa-link"></i>
<i class="icon2 fa fa-edit"></i>
</div>

How to create a pop up animation with a modal using css?

I have already created the modal in css, but when I try changing the transition so that it pops more like a modal instead of fading in, it doesn't work. I've tried changing the duration and the transition type but it doesn't seem to apply. Am I using the wrong transition?
See fiddle: https://jsfiddle.net/mtbh24uL/
.popup {
margin: 70px auto;
padding: 20px;
background: #fff;
border-radius: 5px;
width: 30%;
position: relative;
transition: all 5s ease-in-out;
}
My goal: to have more of a pop up effect like a real javascript modal. I basically need to create a modal like you see in the following picture. I'm not sure what the best approach is or the best plugin.
You could define a CSS animation for that and call this animation when you are clicking on the button. You can achieve this with adding the following CSS code. This is only an example to give you a rough idea of how your effect could look like. From this point you can even optimize and finetune the animation.
CSS
.overlay:target .popup{
animation: popup 0.7s;
}
#keyframes popup {
0%{
transform: scale(1);
}
50%{
transform: scale(1.4);
}
60%{
transform: scale(1.1);
}
70%{
transform: scale(1.2);
}
80%{
transform: scale(1);
}
90%{
transform: scale(1.1);
}
100%{
transform: scale(1);
}
}
body {
font-family: Arial, sans-serif;
background: url(http://www.shukatsu-note.com/wp-content/uploads/2014/12/computer-564136_1280.jpg) no-repeat;
background-size: cover;
height: 100vh;
}
h1 {
text-align: center;
font-family: Tahoma, Arial, sans-serif;
color: #06D85F;
margin: 80px 0;
}
.box {
width: 40%;
margin: 0 auto;
background: rgba(255, 255, 255, 0.2);
padding: 35px;
border: 2px solid #fff;
border-radius: 20px/50px;
background-clip: padding-box;
text-align: center;
}
.button {
font-size: 1em;
padding: 10px;
color: #fff;
border: 2px solid #06D85F;
border-radius: 20px/50px;
text-decoration: none;
cursor: pointer;
/* transition: all 0.3s ease-out; */
}
.button:hover {
background: #06D85F;
}
.overlay {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.7);
transition: opacity 500ms;
visibility: hidden;
opacity: 0;
}
.overlay:target {
visibility: visible;
opacity: 1;
}
.popup {
margin: 70px auto;
padding: 20px;
background: #fff;
border-radius: 5px;
width: 30%;
position: relative;
transition: all 5s ease-in-out;
}
.popup:after {
content: '';
position: absolute;
bottom: 100%;
width: 0;
height: 0;
border-style: solid;
border-width: 0 20px 20px 20px;
border-color: transparent transparent white transparent;
}
.overlay:target .popup {
animation: popup 0.7s;
}
.popup h2 {
margin-top: 0;
color: #333;
font-family: Tahoma, Arial, sans-serif;
}
.popup .close {
position: absolute;
top: 20px;
right: 30px;
transition: all 200ms;
font-size: 30px;
font-weight: bold;
text-decoration: none;
color: #333;
}
.popup .close:hover {
color: #06D85F;
}
.popup .content {
max-height: 30%;
overflow: auto;
}
#media screen and (max-width: 700px) {
.box {
width: 70%;
}
.popup {
width: 70%;
}
}
#keyframes popup {
0% {
transform: scale(1);
}
50% {
transform: scale(1.4);
}
60% {
transform: scale(1.1);
}
70% {
transform: scale(1.2);
}
80% {
transform: scale(1);
}
90% {
transform: scale(1.1);
}
100% {
transform: scale(1);
}
}
<h1>Popup/Modal Windows without JavaScript</h1>
<div class="box">
<a class="button" href="#popup1">Let me Pop up</a>
</div>
<div id="popup1" class="overlay">
<div class="popup">
<h2>Here i am</h2>
<a class="close" href="#">×</a>
<div class="content">
Thank to pop me out of that button, but now i'm done so you can close this window.
</div>
</div>
</div>
In answer to getting the curved arrow, you can use the :after or :before pseudo element. Something like this will achieve the desired effect:
CSS
.popup:after {
content: "";
position: absolute;
border: 0 solid transparent;
border-left: 24px solid white;
border-radius: 33px 0;
top: -18px;
left: 20px;
width: 30px;
height: 34px;
}

Shivering text with CSS transitions

I've tried creating a ripple effect on hover over with a button, the only problem I have is that the text shakes/rattles/shivers when I hover over it, I want it to stay still for a smooth transition. Any ideas on how to stop this?
a {
display: block;
position: relative;
width: 300px;
height: 50px;
background: rgba(0, 0, 255, .2);
text-decoration: none;
text-align: center;
overflow: hidden;
margin: 10% auto;
}
p,
span:first-of-type,
span:last-of-type {
position: absolute;
margin: 0;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 0;
height: 0;
border-radius: 50%;
transition: all .3s;
}
span:first-of-type {
transition-delay: .1s;
z-index: 1;
}
span:last-of-type {
transition-delay: .2s;
z-index: 2;
}
span.cta {
color: #33C;
text-transform: uppercase;
font-family: Arial;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 300px;
display: block;
transition: color .3s;
z-index: 3;
}
a:hover p,
a:hover span:first-of-type,
a:hover span:last-of-type {
width: 110%;
height: 660%;
border-radius: 50%;
background: rgba(0, 0, 255, .2);
}
a:hover span:first-of-type,
a:hover span:last-of-type {
width: 100%;
height: 100%;
}
a:hover p span {
color: #FFF;
}
<a href="#">
<p>
<span></span>
<span class="cta">Shop the Trend</span>
<span></span>
</p>
</a>
N.B. It's fine in IE11, it happens in every other browser.
Here you go...Modified HTML[added button text inside div and applied new class "textCta" to it]
<span class="cta"><div class="textCta">Shop the Trend</div></span>
CSS
.textCta {
color:#33C;
text-transform:uppercase;
font-family:Arial;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
width: 300px;
display: block;
transition: color .3s;
z-index: 3;
}
Demo
By deleting the p tags and placing the actual text within a div, I managed to stop the shivering and still keep the background effect the same.
Thanks to Nofi for their help.
<a href="#">
<span></span>
<div class="cta">Shop the Trend</div>
<span></span>
</a>

Resources