JSFiddle - React, Tailwind, and code Playground
HTML
<section class="welcome-screen">
<div class="content">
<img src="https://www.luck.org.pl/assets/logo-shadow.png">
<div class="header-container">
<h1>Aplikacja już dostępna!</h1>
<h2>Wpisz nazwę Twojego wydarzenia</h2>
<div class="first-step-happening-form">
<div class="lk-inline-input-form">
<input class="lk-input"
type="text"
placeholder="Nazwa wydarzenia..." >
<a class="lk-button">Utwórz</a>
</div>
</div>
</div>
<a class="lk-button underline">Dowiedz się więcej</a>
</div>
</section>
SCSS
section.welcome-screen {
height: calc(100vh - 70px);
width: 100%;
max-width: 100%;
@media screen and (min-width: 414px) {
height: calc(100% - 50px);
}
.content {
height: calc(100% - 113px);
max-width: 1200px;
margin: 0 auto;
padding: 60px 15px 0px 15px;
text-align: center;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: center;
@media screen and (min-width: 414px) {
padding: 70px 40px 30px 40px;
}
.header-container {
padding-bottom: 65px;
}
.first-step-happening-form {
padding: 10px 0 0 0;
.lk-inline-input-form {
width: 100%;
max-width: 280px;
margin: 0 auto;
@media screen and (min-width: 414px) {
max-width: 350px
}
}
}
}
img {
width: 165px;
height: 165px;
@media screen and (min-width: 414px) {
width: 143px;
height: 143px
}
}
h1, h2 {
font-size: 38px;
font-weight: 300;
opacity: 0.85;
letter-spacing: 0px;
margin: 5px 0;
white-space: pre-line;
}
h2 {
font-size: 24px;
font-weight: 300;
opacity: 0.85;
letter-spacing: 0px;
margin: 30px 0 0 0;
}
.lk-button.underline {
font-size: 24px;
font-weight: 300;
opacity: 0.85;
letter-spacing: 0px;
text-transform: inherit;
}
}
JavaScript
(function () {
const welcomeScreen = document.getElementsByClassName('welcome-screen')[0];
const oryginalHeight = window.innerHeight
function getPercent(a, b) {
return (b !== 0) ? mathRound(a * 100 / b) : 0;
}
function mathRound(number) {
return Number(Math.round(number * 100).toFixed(2) / 100);
}
window.addEventListener('resize', () => {
const currentHeight = window.innerHeight;
const newHeight = getPercent(oryginalHeight, currentHeight);
console.log('resize', oryginalHeight, currentHeight, newHeight)
welcomeScreen.style.height = `${newHeight}vh`
});
})();