.card
h1 3D Button with Shading (Experiment)
div
button.btn Default
button.btn.btn-info Information
button.btn.btn-success Success
button.btn.btn-warning Warning
button.btn.btn-error Error
button.btn.btn-dark Dark
//- Custom style by setting the prepared variables
button.btn(style="--color: #ffffff; --background-color: #ff4081; --border-color: #ec407a;") Jelly beans
View Compiled
////////////////////////////////////////////////////////////////////////////////
// IF YOU WANT TO USE THIS STYLE, PLEASE READ THIS //
////////////////////////////////////////////////////////////////////////////////
// This is written in SCSS. If you would like to use the CSS, you may compile //
// the code, then use the CSS style on your own project. //
// Please take note that the code above the block of comment: //
// STYLES RELATED TO EXPERIMENT BUTTONS //
// Is just for the styling of the page. These are not related to the styles //
// of the buttons. So after compiling to CSS, you may just take the part //
// on or below the said block of comments. //
// You may also customize the colors of the buttons, or actually add a new //
// class for the buttons, by editing the $btn-type map before compiling the //
// source code into CSS. //
////////////////////////////////////////////////////////////////////////////////
@import url("https://fonts.googleapis.com/css?family=Open+Sans:400,400i,700");
body {
font-family: "Open Sans", sans-serif;
font-size: 16px;
background-color: #e2e2e2;
width: 100vw;
height: 100vh;
display: flex;
}
.card {
background-color: #ffffff;
width: calc(100% - 4rem);
padding: 4rem 2rem;
border: solid 1px #eaeaea;
margin: auto;
border-radius: 2.5rem;
box-sizing: border-box;
box-shadow: 0 1rem 2rem rgba(#000000, 0.3);
h1 {
text-align: center;
padding: 0;
margin: 0;
margin-bottom: 2rem;
}
div {
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
}
}
.btn {
margin-bottom: 0.5rem;
margin-right: 0.5rem;
&:last-child {
margin-right: 0;
}
}
@media screen and (min-width: 960px) {
.card {
width: calc(960px - 4rem);
}
}
/******************************************************************************/
/* STYLES RELATED TO EXPERIMENT BUTTONS */
/******************************************************************************/
$btn-padding: 0.6rem 0.9rem;
$btn-border-radius: 0.5rem;
$btn-transition-time: 64ms;
// The Map for the CSS class of the buttons
$btn-type: (
"info": (
"color": #ffffff,
"background-color": #0091ea,
),
"success": (
"color": #ffffff,
"background-color": #00c853,
),
"warning": (
"color": #3e2723,
"background-color": #ffc400,
),
"error": (
"color": #ffffff,
"background-color": #d50000,
),
"dark": (
"color": #ffffff,
"background-color": #303030,
),
);
.btn {
--color: #000000;
--background-color: #d8d8d8;
--border-color: darken(#d8d8d8, 7.5%);
color: var(--color);
font-family: inherit;
background-color: var(--background-color);
padding: $btn-padding;
border: solid 1px var(--border-color);
outline: none;
position: relative;
border-radius: $btn-border-radius;
user-select: none;
box-shadow:
0 0.2rem 0.4rem rgba(0, 0, 0, 0.4),
0 -0.3rem 0.6rem rgba(0, 0, 0, 0.2) inset;
transition: box-shadow $btn-transition-time ease-out;
&:after {
content: "";
background-color: #ffffff;
width: 75%;
height: 12.5%;
position: absolute;
top: 0.15rem;
left: 12.5%;
border-radius: 50%;
filter: blur(0.15rem);
transition: opacity $btn-transition-time ease-out;
}
&:active {
box-shadow:
0 0 0 rgba(0, 0, 0, 0.4),
0 0.4rem 1rem rgba(0, 0, 0, 0.3) inset;
&:after {
opacity: 0;
}
}
}
@each $type, $styles in $btn-type {
.btn-#{$type} {
@each $style, $value in $styles {
--#{$style}: #{$value};
@if ($style == "background-color") {
--border-color: #{darken($value, 7.5%)};
}
&:active {
@if ($style == "color") {
--#{$style}: #{darken($value, 7.5%)};
}
}
}
}
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.