<div class="container">
<details class="default square">
<summary>Click to <span class="open">open</span><span class="close">close</span></summary>
<p>If your browser supports this element, it should allow you to expand and collapse these details.</p>
</details>
<details class="primary square">
<summary>Click to <span class="open">open</span><span class="close">close</span></summary> <p>If your browser supports this element, it should allow you to expand and collapse these details.</p>
</details>
<details class="success">
<summary>Click to <span class="open">open</span><span class="close">close</span></summary> <p>If your browser supports this element, it should allow you to expand and collapse these details.</p>
</details>
</div>
// Colors
$default: #878d99;
$primary: #409eff;
$sucess: #67c23a;
// Some Reset
html,
body {
width: 100%;
height: 100%;
padding: 0;
overflow: hidden;
font-family: "Open Sans", sans-serif;
}
body {
display: flex;
justify-content: center;
align-items: center;
}
.container {
width: 450px;
height: 376px;
}
// Change component color
@mixin states($color: $default) {
border-color: $color;
color: rgba(255, 255, 255, 0.9);
background: $color;
&:hover {
border-color: $color;
color: rgba(255, 255, 255, 0.6);
}
&:active {
color: rgba(255, 255, 255, 0.9);
border-color: darken($color, 10%);
}
}
// Collapse / Expand Component
details {
@include states($default);
border: 1px solid;
cursor: pointer;
transition: background 0.3s;
border-radius: 4px;
min-height: 48px;
max-height: 60px;
transform-origin: top center;
transform: rotate(0.1deg);
transition: all 0.3s;
::-webkit-details-marker {
display: none;
}
+ details {
margin-top: 10px;
}
p {
color: #fefefe;
line-height: 1.7;
margin: 10px 0 0;
padding: 0 20px 15px;
}
// Primary Style
&.primary {
@include states($primary);
}
// Success Style
&.success {
@include states($sucess);
}
// Square Style
&.square {
border-radius: 0;
}
&[open] {
transition: all 0.6s;
min-height: 100px;
max-height: 200px;
}
}
summary {
outline: none;
font-size: 16px;
padding: 13px;
&:selection {
background: transparent;
}
.close {
display: none;
[open] & {
display: inline;
}
}
.open {
display: inline;
[open] & {
display: none;
}
}
[open] & {
display: inline;
}
&:after {
margin-top: 2px;
content: "➕";
float: left;
margin-right: 11px;
text-align: center;
font-size: 11px;
[open] & {
padding: 0 0 12px 0;
content: "➖";
}
}
}
View Compiled
This Pen doesn't use any external JavaScript resources.