<div class="example bg-1">
<section class="panel">
<header class="panel__header">
<h1 class="panel__title">
Panel on a blue background
</h1>
</header>
<div class="panel__content">
This panel picks up the blue color below.
</div>
</section>
</div>
<div class="example bg-2">
<section class="panel">
<header class="panel__header">
<h1 class="panel__title">
Panel on a green background
</h1>
</header>
<div class="panel__content">
This panel picks up the green color below.
</div>
</section>
</div>
<div class="example bg-3">
<section class="panel">
<header class="panel__header">
<h1 class="panel__title">
Panel on a pink background
</h1>
</header>
<div class="panel__content">
This panel picks up the pink color below.
</div>
</section>
</div>
:root {
--panel-color: rgba(0, 0, 0, 0.135);
--panel-border-width: 0.1em;
--panel-padding: 0.75em;
}
.panel {
background: var(--panel-color);
border-radius: var(--panel-border-width);
padding: var(--panel-border-width);
}
.panel__header,
.panel__content {
padding: var(--panel-padding);
}
.panel__title {
line-height: 1;
}
.panel__content {
background: #fff;
}
/**
* The styles below are unrelated to this demo and are just for scaffolding purposes.
*/
* {
font-family: sans-serif;
line-height: 1.4;
margin: 0;
padding: 0;
}
html {
height:100%;
display: flex;
}
body {
display: flex;
flex-direction: column;
flex-grow: 1;
}
.example {
display: flex;
flex-grow: 1;
padding: 1em max(1em, calc(50vw - 35ch));
place-items: center;
}
.example > * {
flex-grow: 1;
}
.bg-1 {
background: #cbe4f2;
}
.bg-2 {
background: #b1d3b2;
}
.bg-3 {
background: #f7c0b9;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.