CSS Custom Text Selection
02/04/2021
Demo
Code
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>CSS Custom Text Selection</title>
<link rel="stylesheet" type="text/css" href="https://demo.plantpot.works/assets/css/normalize.css">
<link rel="stylesheet" href="https://use.typekit.net/opg3wle.css">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="container">
<h1 class="text">CSS Custom<br>Text Selection</h1>
</div>
</body>
</html>
CSS
@charset "utf-8";
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html {
font-size: 16px;
}
body {
background-color: #ff83c1;
font-family: futura-pt, sans-serif;
-webkit-tap-highlight-color: rgba(0,0,0,0);
}
#container {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100vh;
padding: 10px;
}
.text {
margin: 0;
color: #00011f;
font-size: 4rem;
letter-spacing: 2px;
text-align: center;
}
.text::selection {
color: #fff;
background-color: #00011f;
text-shadow: 4px 4px #92ded2;
}
@media screen and (max-width: 480px) {
.text {
font-size: 2rem;
}
}