<div class="solid"></div>
<div class="outline"></div>
<div class="pseudo elements"></div>
<div class="linear-gradient"></div>
<div class="box-shadow"></div>
<div class="border-image"></div>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
width: 100vw;
padding: 10px;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(30vw, 1fr));
grid-gap: 10px;
}
div {
height: 150px;
color: #000;
position: relative;
&::before {
content: attr(class);
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font: 600 1.5em/ 1.375 segoe script, comic sans ms, cursive;
text-shadow: 1px 1px #000;
white-space: nowrap;
}
&[class="solid"] {
border: 1em solid currentColor;
}
&[class="outline"] {
margin: 1em;
height: calc(150px - 2em);
outline: 1em solid;
}
&[class="pseudo elements"] {
background: linear-gradient(to right, #fff, #fff);
position: relative;
padding: 1em;
background-clip: content-box;
&::after {
content: '';
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: #000;
z-index: -1;
}
}
&[class="linear-gradient"] {
padding: 1em;
background: linear-gradient(to right, #fff, #fff), #000;
background-clip: content-box, padding-box;
}
&[class="box-shadow"] {
width: calc(100% - 2em);
height: calc(150px - 2em);
margin: 1em auto;
box-shadow: 0 0 0 1em #000;
}
&[class="border-image"] {
border: 1em solid transparent;
border-image: linear-gradient(to right, #000, #000) 10% round;
}
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.