Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2b99506

Browse files
committed
Added Project #12 - Custom Checkbox and Card
1 parenta55d57e commit2b99506

File tree

3 files changed

+129
-0
lines changed

3 files changed

+129
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!DOCTYPE html>
2+
<htmllang="en">
3+
<head>
4+
<metacharset="UTF-8"/>
5+
<metaname="viewport"content="width=device-width, initial-scale=1.0"/>
6+
<linkrel="stylesheet"href="style.css"/>
7+
<title>Document</title>
8+
</head>
9+
<body>
10+
<sectionclass="switch-container">
11+
<h1>Competency Level? (Optional)</h1>
12+
<labelfor="beginner">
13+
<inputtype="checkbox"class="checkbox"id="beginner"/>
14+
<divclass="switch"></div>
15+
Beginner
16+
</label>
17+
<labelfor="advanced">
18+
<inputtype="checkbox"class="checkbox"id="advanced"/>
19+
<divclass="switch"></div>
20+
Advanced
21+
</label>
22+
</section>
23+
24+
<scriptsrc="script.js"defer></script>
25+
</body>
26+
</html>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
constcheckboxes=document.querySelectorAll(".checkbox");
2+
constbeginner=document.getElementById("beginner");
3+
constadvanced=document.getElementById("advanced");
4+
checkboxes.forEach((checkbox)=>{
5+
checkbox.addEventListener("click",(e)=>{
6+
if(beginner===e.target){
7+
advanced.checked=false;
8+
}
9+
if(advanced===e.target){
10+
beginner.checked=false;
11+
}
12+
});
13+
});
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
body {
2+
font-family:"Montserrat","Poppins";
3+
display: grid;
4+
place-items: center;
5+
min-height:100vh;
6+
background-color: aliceblue;
7+
}
8+
9+
.switch-container {
10+
padding:4rem;
11+
background-color:#fff;
12+
border-radius:0.5rem;
13+
/* box-shadow: offset-x | offset-y | blur-radius | spread radius | color */
14+
box-shadow:#86bffb0px0px0px6px inset,
15+
rgb(255,255,255)25px-25px0px-6px,rgb(176,216,175)25px-25px,
16+
rgb(255,255,255)45px-45px0px-6px,rgb(235,221,153)45px-45px,
17+
rgb(255,255,255)65px-65px0px-6px,rgb(245,178,130)65px-65px,
18+
rgb(255,255,255)85px-85px0px-6px,rgb(255,161,161)85px-85px;
19+
}
20+
21+
.switch-containerh1 {
22+
font-size:3rem;
23+
color:#343434;
24+
}
25+
26+
label {
27+
display: flex;
28+
align-items: center;
29+
font-size:2.5rem;
30+
user-select: none;
31+
color:#343434;
32+
-moz-user-select: none;
33+
-webkit-user-select: none;
34+
cursor: pointer;
35+
margin:1.5rem0;
36+
}
37+
38+
label .checkbox {
39+
display: none;
40+
}
41+
42+
.switch {
43+
position: relative;
44+
width:90px;
45+
height:40px;
46+
background-color:#dddcdc;
47+
transition-delay:0.2s;
48+
margin-right:1rem;
49+
border-radius:30px;
50+
}
51+
52+
.switch::before {
53+
position: absolute;
54+
content:"";
55+
width:36px;
56+
height:36px;
57+
background-color:#fff;
58+
margin:2px;
59+
border-radius:50%;
60+
transform:scale(1.3);
61+
box-shadow:0px2px1px-1pxrgba(0,0,0,0.2),
62+
0px1px1px0pxrgba(0,0,0,0.14),0px1px3px0pxrgba(0,0,0,0.12);
63+
transition: margin0.3s ease-in-out;
64+
}
65+
66+
.switch:hover::before {
67+
box-shadow:000px3pxrgba(0,0,0,0.12);
68+
}
69+
70+
.checkbox:checked+ .switch {
71+
background-color:#69b0fd;
72+
}
73+
74+
.checkbox:checked+ .switch:hover:before {
75+
box-shadow:000px3pxrgba(69,153,250,0.445);
76+
}
77+
78+
.checkbox:checked+ .switch::before {
79+
margin-left:54px;
80+
animation: throwShadow0.3s ease-in-out;
81+
}
82+
83+
@keyframes throwShadow {
84+
from {
85+
box-shadow:000px0pxrgb(170,231,250);
86+
}
87+
to {
88+
box-shadow:003px3pxrgb(101,208,241);
89+
}
90+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp