<div class="container"><h1>Switch from light to dark mode using the toggle(^_^)</h1>
<div class="node">
<p>Using the :checked pseudo-class selector, one can style descendants and subsequent siblings of a checkbox when it is in checked state.</p>
<p>Having both a checkbox for enabling dark mode and an element containing all other content on the page on the same level of the DOM tree allows us to offer a CSS-only dark mode of a web page.</p>
<p>macOS Mojave adds a Dark Mode for native apps that makes you look approximately 78 percent cooler when using the computer. In Safari Technology Preview 68, it’s now available on webpages too! Here’s how I added support to this website.</p>
<div class="action">
<button>More...</button>
</div>
</div>
</div>
@import url('//fonts.googleapis.com/css?family=Lato:400,400italic,700|Sansita+One');
@import url("https://fonts.googleapis.com/css?family=Merriweather:400,400i,700");
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html, body {
width: 100vw;
min-height: 100vh;
}
body {
display: flex;
justify-content: center;
}
.theme-container {
flex: 1;
width: 100vw;
display: flex;
justify-content: center;
padding-top: 130px;
}
.container {
max-width: 80vw;
width: 60vw;
display: flex;
flex-direction: column;
align-items: center;
}
h1 {
font-family: "Sansita One", serif;
font-size: 2rem;
margin-bottom: 1vh;
}
.node {
&::before {
content: '';
float: left;
width: 546px;
height: 805px;
background: url('https://www.footyrenders.com/render/Neymar-45.png');
background-size: cover;
shape-outside: polygon(55px -1px, 9.57% 8.45%, 15.06% 17.15%, 0.41% 20.5%, -6.92% 29.07%, -22.67% 35.16%, -50.89% 41.37%, -75.8% 43.73%, -79.44% 49.93%, -58.94% 52.06%, -47.95% 47.33%, -3.26% 39.75%, -9.85% 47.7%, -39.52% 51.3%, -64.43% 58.76%, -73.59% 77.77%, -94.47% 84.85%, -93.73% 90.56%, -53.07% 84.1%, -40.26% 67.45%, 0.77% 67.58%, -8.42% 80.59%, -21.22% 90.42%, -20.84% 99.38%, -4.57% 97.33%, 13.13% 101.34%, 28.72% 94.26%, 43.75% 74.89%, 56.35% 62.5%, 76.74% 24.41%, 101.7% 17.48%, 101.87% 14.32%, 92.52% 11.73%, 74.31% 6.78%, 57.63% 1.97%);
shape-margin: 10px;
margin-left: -273px;
}
}
p {
font-family: Merriweather, serif;
font-size: 1.1rem;
line-height: 1.6rem;
margin: 1rem 0;
}
button {
-webkit-appearance: none;
background-color: transparent;
background-repeat: no-repeat;
background-image: linear-gradient(-60deg, #ff4cff 0%, #ff4cff 41.6%, #5bf390 41.6%, #5bf390 100%), linear-gradient(-60deg, #ff4cff 0%, #ff4cff calc(100% - 41.6%), #5bf390 calc(100% - 41.6%), #5bf390 100%);
background-position: 0 0, 0 100%, 0 0, 100% 0;
background-size: 100% 0.3em, 100% 0.3em, calc(100% + 0.6em) 100%, 100% calc(100% + 0.6em);
border: none;
border-left: 0.3em solid #5bf390;
border-right: 0.3em solid #ff4cff;
padding: 1.3em 2.8em;
line-height: 1;
overflow: hidden;
position: relative;
font-size: 1em;
font-weight: 400;
transition: all 0.4s;
outline: none !important;
font-family: "Sansita One", serif;
color: var(--c-text);
&::before,
&::after {
content: '';
display: block;
position: absolute;
z-index: -1;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-repeat: no-repeat;
transition: all 0.4s;
}
&::before {
background-image: linear-gradient(-66deg, transparent 0%, transparent 50%, #5bf390 50%, #5bf390 100%);
transform: translateX(calc(-100% + 41.6%));
}
&::after {
background-image: linear-gradient(114deg, transparent 0%, transparent 50%, #ff4cff 50%, #ff4cff 100%);
transform: translateX(calc(100% - 41.6%));
}
&:hover,
&:active{
// color: white;
&::before,
&::after {
transform: translateX(0);
}
}
}
// dark & light mode
:root {
/* Light theme */
--c-text: #333;
--c-background: #fff;
}
body {
color: var(--c-text);
background-color: var(--c-background);
}
@media (prefers-color-scheme: dark) {
:root {
/* Dark theme */
--c-text: #fff;
--c-background: #333;
}
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.