I tried to add an animation for my form submit button on my Todo list.
Unfortunately, the same button animation works outside form, but inside form only can hover the text. I have no idea where the problem is?
JavaScript
x
20
20
1
import React from "react";
2
3
class TodoForm extends React.Component {
4
render() {
5
return (
6
<div>
7
<div className={"container"}>
8
<form action="">
9
<h1>Todo List</h1>
10
<input type="text" placeholder={""}/>
11
<button className="custom-btn btn">Submit</button>
12
</form>
13
<button className="custom-btn btn">Submit</button>
14
</div>
15
</div>
16
);
17
}
18
}
19
20
export default TodoForm;
JavaScript
1
83
83
1
.container {
2
display: flex;
3
flex-direction: row;
4
/*align-items: center;*/
5
justify-content: center;
6
margin-top: 5%;
7
}
8
9
form {
10
height: 500px;
11
width: 400px;
12
background-color: #f4f7fc;
13
border: 2px solid;
14
border-radius: 10px;
15
box-shadow:8px 8px 5px;
16
text-align: center;
17
}
18
19
h1 {
20
font-family: 'Orbitron', sans-serif;
21
font-weight: 900;
22
}
23
24
input[type='text'] {
25
border: 1px solid #ddd;
26
height: 6%;
27
min-width: 60%;
28
transition: all ease-in 0.25s;
29
}
30
31
.custom-btn {
32
margin-left: 5px;
33
width: 25%;
34
height: 37px;
35
border-radius: 5px;
36
background: transparent;
37
cursor: pointer;
38
transition: all 0.3s ease;
39
position: relative;
40
display: inline-block;
41
outline: none;
42
}
43
44
.custom-btn, input[type='text'] {
45
box-shadow: 1px 1px 1px 0px rgba(255,255,255,.5),
46
7px 7px 20px 0px rgba(0,0,0,.1),
47
4px 4px 5px 0px rgba(0,0,0,.1);
48
}
49
50
.btn {
51
border: 2px solid #f4f7fc;
52
color: #f59cb1;
53
font-family: 'Orbitron', sans-serif;
54
font-weight: 900;
55
56
}
57
.btn:after {
58
position: absolute;
59
content: "";
60
width: 0;
61
height: 100%;
62
top: 0;
63
left: 0;
64
direction: rtl;
65
z-index: -1;
66
box-shadow:
67
-7px -7px 20px 0px #fff9,
68
-4px -4px 5px 0px #fff9,
69
7px 7px 20px 0px #0002,
70
4px 4px 5px 0px #0001;
71
transition: all 0.3s ease;
72
}
73
.btn:hover {
74
color: #FF6F91;
75
}
76
.btn:hover:after {
77
left: auto;
78
right: 0;
79
width: 100%;
80
}
81
.btn:active {
82
top: 2px;
83
}
JavaScript
1
2
1
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
2
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
Advertisement
Answer
The background color doesn’t let you see the animation, just comment it;
JavaScript
1
10
10
1
form {
2
height: 500px;
3
width: 400px;
4
/*background-color: #f4f7fc;*/
5
border: 2px solid;
6
border-radius: 10px;
7
box-shadow:8px 8px 5px;
8
text-align: center;
9
}
10