JSFiddle - React, Tailwind, and code Playground
by NunoMira
HTML
<!-- modal 1 -->
<a href="#m1-o" id="m1-c">Modal 1</a>
<div class="modal-container" id="m1-o" style="--m-background: transparent;">
<div class="modal">
<h1 class="modal__title">Modal 1 Title</h1>
<p class="modal__text">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Facilis ex dicta maiores libero minus obcaecati iste optio, eius labore repellendus.</p>
<button class="modal__btn">Button →</button>
<a href="#m1-c" class="link-2"></a>
</div>
</div>
<!-- /modal 1 -->
CSS
/*
================================
Best Viewed In Full Page
================================
*/
/* Because I'm using the fixed position for modals, if the screen height is small then you would not be able to see a full modal that's why it's recommended that you see this pen in full-page and not on editor view. */
/* defaults */
*,
*::after,
*::before {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
font-size: 62.5%;
}
body {
--light: hsl(220, 50%, 90%);
--primary: hsl(255, 30%, 55%);
--focus: hsl(210, 90%, 50%);
--border-color: hsla(0, 0%, 100%, .2);
--global-background: hsl(220, 25%, 10%);
--background: linear-gradient(to right, hsl(210, 30%, 20%), hsl(255, 30%, 25%));
--shadow-1: hsla(236, 50%, 50%, .3);
--shadow-2: hsla(236, 50%, 50%, .4);
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Open Sans', sans-serif;
color: var(--light);
background: var(--global-background);
}
a,
a:link {
font-family: inherit;
text-decoration: none;
}
a:focus {
outline: none;
}
button::-moz-focus-inner {
border: 0;
}
/* box */
.box {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
padding: 0 4rem 2rem;
}
.box:not(:first-child) {
height: 45rem;
}
.box__title {
font-size: 10rem;
font-weight: normal;
letter-spacing: .8rem;
margin-bottom: 2.6rem;
}
.box__title::first-letter {
color: var(--primary);
}
.box__p,
.box__info,
.box__note {
font-size: 1.6rem;
}
.box__info {
margin-top: 6rem;
}
.box__note {
line-height: 2;
}
/* modal */
.modal-container {
position: fixed;
top: 0;
left: 0;
z-index: 10;
display: none;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
/* --m-background is set as inline style */
background: var(--m-background);
}
/* using :target */
/*
when users will click/enter button(link) browser will add a #id in a url and when that happens we'll show our...