In web design and development, HTML and CSS are used to fulfill specialized button needs, like simulating a keyboard shift button. This button mimics the keyboard’s shift key for specific functions such as triggering caps lock.
By replicating the keyboard shift button, we create a button that looks and behaves like the actual keyboard shift key.
Here is the specific code:
HTML
<button class="button">
shift
</button>
CSS
.button {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: flex-end;
background-color: #000;
color: #fff;
font-size: 16px;
letter-spacing: 1px;
border: 0.5px solid rgba(0, 0, 0, 0.1);
padding-bottom: 8px;
height: 65px;
width: 200px;
padding: 12px;
border-radius: 15px 15px 12px 12px;
cursor: pointer;
position: relative;
will-change: transform;
transition: all .1s ease-in-out 0s;
user-select: none;
/* Add gradient shading to each side */
background-image: linear-gradient(to right, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0)),
linear-gradient(to bottom, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0));
background-position: bottom right, bottom right;
background-size: 100% 100%, 100% 100%;
background-repeat: no-repeat;
box-shadow: inset -4px -10px 0px rgba(255, 255, 255, 0.4),
inset -4px -8px 0px rgba(0, 0, 0, 0.3),
0px 2px 1px rgba(0, 0, 0, 0.3),
0px 2px 1px rgba(255, 255, 255, 0.1);
transform: perspective(70px) rotateX(5deg) rotateY(0deg);
}
.button span {
transform: translateY(-10px);
}
.button::after {
content: '';
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.2), rgba(0, 0, 0, 0.5));
z-index: -1;
border-radius: 15px;
box-shadow: inset 4px 0px 0px rgba(255, 255, 255, 0.1),
inset 4px -8px 0px rgba(0, 0, 0, 0.3);
transition: all .1s ease-in-out 0s;
}
.button::before {
content: '';
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-image: linear-gradient(to right, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0)),
linear-gradient(to bottom, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0));
background-position: bottom right, bottom right;
background-size: 100% 100%, 100% 100%;
background-repeat: no-repeat;
z-index: -1;
border-radius: 15px;
transition: all .1s ease-in-out 0s;
}
.button:active {
will-change: transform;
transform: perspective(80px) rotateX(5deg) rotateY(1deg) translateY(3px) scale(0.96);
height: 64px;
border: 0.25px solid rgba(0, 0, 0, 0.2);
box-shadow: inset -4px -8px 0px rgba(255, 255, 255, 0.2),
inset -4px -6px 0px rgba(0, 0, 0, 0.8),
0px 1px 0px rgba(0, 0, 0, 0.9),
0px 1px 0px rgba(255, 255, 255, 0.2);
transition: all .1s ease-in-out 0s;
}
.button::after:active {
background-image: linear-gradient(to bottom,rgba(0, 0, 0, 0.5), rgba(255, 255, 255, 0.2));
}
.button:active::before {
content: "";
display: block;
position: absolute;
top: 5%;
left: 20%;
width: 50%;
height: 80%;
background-color: rgba(255, 255, 255, 0.1);
animation: overlay 0.1s ease-in-out 0s;
pointer-events: none;
}
.button svg {
width: 15px;
height: 15px;
}
@keyframes overlay {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
.button:focus {
outline: none;
}
HTML & CSS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.button {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: flex-end;
background-color: #000;
color: #fff;
font-size: 16px;
letter-spacing: 1px;
border: 0.5px solid rgba(0, 0, 0, 0.1);
padding-bottom: 8px;
height: 65px;
width: 200px;
padding: 12px;
border-radius: 15px 15px 12px 12px;
cursor: pointer;
position: relative;
will-change: transform;
transition: all .1s ease-in-out 0s;
user-select: none;
/* Add gradient shading to each side */
background-image: linear-gradient(to right, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0)),
linear-gradient(to bottom, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0));
background-position: bottom right, bottom right;
background-size: 100% 100%, 100% 100%;
background-repeat: no-repeat;
box-shadow: inset -4px -10px 0px rgba(255, 255, 255, 0.4),
inset -4px -8px 0px rgba(0, 0, 0, 0.3),
0px 2px 1px rgba(0, 0, 0, 0.3),
0px 2px 1px rgba(255, 255, 255, 0.1);
transform: perspective(70px) rotateX(5deg) rotateY(0deg);
}
.button span {
transform: translateY(-10px);
}
.button::after {
content: '';
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.2), rgba(0, 0, 0, 0.5));
z-index: -1;
border-radius: 15px;
box-shadow: inset 4px 0px 0px rgba(255, 255, 255, 0.1),
inset 4px -8px 0px rgba(0, 0, 0, 0.3);
transition: all .1s ease-in-out 0s;
}
.button::before {
content: '';
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-image: linear-gradient(to right, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0)),
linear-gradient(to bottom, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0));
background-position: bottom right, bottom right;
background-size: 100% 100%, 100% 100%;
background-repeat: no-repeat;
z-index: -1;
border-radius: 15px;
transition: all .1s ease-in-out 0s;
}
.button:active {
will-change: transform;
transform: perspective(80px) rotateX(5deg) rotateY(1deg) translateY(3px) scale(0.96);
height: 64px;
border: 0.25px solid rgba(0, 0, 0, 0.2);
box-shadow: inset -4px -8px 0px rgba(255, 255, 255, 0.2),
inset -4px -6px 0px rgba(0, 0, 0, 0.8),
0px 1px 0px rgba(0, 0, 0, 0.9),
0px 1px 0px rgba(255, 255, 255, 0.2);
transition: all .1s ease-in-out 0s;
}
.button::after:active {
background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), rgba(255, 255, 255, 0.2));
}
.button:active::before {
content: "";
display: block;
position: absolute;
top: 5%;
left: 20%;
width: 50%;
height: 80%;
background-color: rgba(255, 255, 255, 0.1);
animation: overlay 0.1s ease-in-out 0s;
pointer-events: none;
}
.button svg {
width: 15px;
height: 15px;
}
@keyframes overlay {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
.button:focus {
outline: none;
}
</style>
</head>
<body>
<button class="button">
shift
</button>
</body>
</html>
THE END
No comments