250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- MAC
- javascript
- 백엔드
- effect
- HTML
- CSS
- iPhone
- hover
- 개발자
- SWIFT
- html5
- xcode
- Animation
- 풀스택
- 자바스크립트
- front-end
- php
- react
- ipad
- jQuery
- iOS 개발자
- 비전공자
- image
- 애니메이션
- button
- keyframes
- IOS
- 비전공 개발자
- 프론트엔드
- css3
Archives
- Today
- Total
비전공자 개발일기
Javascript - Split Landing Page 본문
728x90
SMALL
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Split Landing Page</title>
<link rel="stylesheet" href="style.css">
<script defer src="main.js"></script>
</head>
<body>
<div class="container">
<div class="split left">
<h1>Playstation 5</h1>
<a href="#" class="btn">Buy Now</a>
</div>
<div class="split right">
<h1>XBox Series X</h1>
<a href="#" class="btn">Buy Now</a>
</div>
</div>
</body>
</html>
@import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap');
:root {
--left-bg-color: rgba(87, 84, 263, .7);
--right-bg-color: rgba(43, 43, 43, .8);
--left-btn-hover-color: rgba(87, 84, 236, 1);
--right-btn-hover-color: rgba(28, 122, 28, 1);
--hover-width: 75%;
--other-width: 25%;
--speed: 1s;
}
* {
box-sizing: border-box;
}
body {
font-family: 'Roboto', sans-serif;
height: 100vh;
overflow: hidden;
margin: 0;
}
h1 {
font-size: 4rem;
color: #fff;
position: absolute;
left: 50%;
top: 20%;
transform: translateX(-50%);
white-space: nowrap;
}
.btn {
position: absolute;
display: flex;
align-items: center;
justify-content: center;
left: 50%;
top: 40%;
transform: translateX(-50%);
text-decoration: none;
color: #fff;
border: 0.2rem solid #fff;
font-size: 1rem;
font-weight: bold;
text-transform: uppercase;
width: 15rem;
padding: 1.5rem;
}
.split.left .btn:hover {
background-color: var(--left-btn-hover-color);
border-color: var(--left-btn-hover-color)
}
.split.right .btn:hover {
background-color: var(--right-btn-hover-color);
border-color: var(--right-btn-hover-color)
}
.container {
position: relative;
width: 100%;
height: 100%;
background: #333;
}
.split {
position: absolute;
width: 50%;
height: 100%;
overflow: hidden;
}
.split.left {
left: 0;
background:url("ps.jpg");
background-repeat: no-repeat;
background-size: cover;
}
.split.left::before {
content: '';
position: absolute;
width: 100%;
height: 100%;
background-color: var(--left-bg-color);
}
.split.right {
right: 0;
background:url("xbox.jpg");
background-repeat: no-repeat;
background-size: cover;
}
.split.right::before {
content: '';
position: absolute;
width: 100%;
height: 100%;
background-color: var(--right-bg-color);
}
.split.right, .split.left, .split.right::before, .split.left::before {
transition: all var(--speed) ease-in-out;
}
.hover-left .left {
width: var(--hover-width);
}
.hover-left .right {
width: var(--other-width);
}
.hover-right .right {
width: var(--hover-width);
}
.hover-right .left {
width: var(--other-width);
}
@media (max-width: 800px) {
h1 {
font-size: 2rem;
top: 30%;
}
.btn {
padding: 1.2rem;
width: 12rem;
}
}
const left = document.querySelector(".left");
const right = document.querySelector(".right");
const container = document.querySelector(".container");
left.addEventListener("mouseenter", () => {container.classList.add("hover-left")});
left.addEventListener("mouseleave", () => {container.classList.remove("hover-left")});
right.addEventListener("mouseenter", () => {container.classList.add("hover-right")});
right.addEventListener("mouseleave", () => {container.classList.remove("hover-right")});
728x90
LIST
'Javascript' 카테고리의 다른 글
Javascript - Sound Board (0) | 2021.10.02 |
---|---|
Javascript - Form Wave Animation (0) | 2021.10.01 |
Javascript - Scroll Animation (0) | 2021.09.29 |
Javascript - Hidden Search (0) | 2021.09.28 |
Javascript - Rotating Navigation (0) | 2021.09.27 |