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
- CSS
- css3
- button
- ipad
- Animation
- react
- 백엔드
- image
- 프론트엔드
- SWIFT
- keyframes
- 자바스크립트
- xcode
- HTML
- IOS
- 애니메이션
- front-end
- hover
- 비전공 개발자
- 개발자
- effect
- iOS 개발자
- javascript
- jQuery
- 비전공자
- MAC
- php
- iPhone
- html5
- 풀스택
Archives
- Today
- Total
비전공자 개발일기
Aspect Ratio Calculator 본문
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>ASPECT RATIO CALCULATOR</title>
<link
href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="style.css">
<script defer src="main.js"></script>
</head>
<body>
<div class="container">
<h2>
<span>Aspect Ratio</span>
</h2>
<div class="wrapper-1">
<input type="number" id="ratio-width" value="16" />
<input type="number" id="ratio-height" value="9" />
</div>
<div class="box">
<div class="wrapper-2">
<label for="width">Width:</label>
<input type="number" id="width" value="1280" />
</div>
<div class="wrapper-3">
<label for="height">Height:</label>
<input type="number" id="height" value="720" />
</div>
</div>
</div>
</body>
</html>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
font-family: "Poppins", sans-serif;
}
body {
background-color: #895cf3;
}
.container {
width: 500px;
background-color: #ffffff;
padding: 80px 40px;
position: absolute;
transform: translate(-50%, -50%);
top: 50%;
left: 50%;
border-radius: 10px;
box-shadow: 0 30px 45px rgba(18, 8, 39, 0.2);
}
h2 {
text-align: center;
font-size: 40px;
line-height: 1.6;
font-weight: 600;
letter-spacing: 2px;
}
h2 span {
color: #895cf3;
}
.wrapper-1 {
display: flex;
justify-content: center;
align-items: center;
margin: 50px 0 70px 0;
gap: 10px;
}
.wrapper-1 input {
width: 100px;
font-size: 30px;
font-weight: 600;
}
input {
padding: 15px 10px;
border: 1px solid #bbc0c5;
border-radius: 5px;
color: #170444;
outline: none;
}
input:focus {
border: 2px solid #895cf3;
}
label {
color: #170444;
font-weight: 600;
letter-spacing: 0.6px;
}
.box {
display: flex;
justify-content: space-between;
gap: 30px;
}
.wrapper-2,
.wrapper-3 {
display: flex;
flex-direction: column;
gap: 15px;
}
.wrapper-2 input,
.wrapper-3 input {
width: 100%;
font-size: 18px;
}
let ratioWidth = document.getElementById("ratio-width");
let ratioHeight = document.getElementById("ratio-height");
let width = document.getElementById("width");
let height = document.getElementById("height");
let calculateWidth = () => {
let aspectRatio = ratioWidth.value / ratioHeight.value;
width.value = parseFloat((height.value * aspectRatio).toFixed(2));
};
let calculateHeight = () => {
let aspectRatio = ratioWidth.value / ratioHeight.value;
height.value = parseFloat((width.value / aspectRatio).toFixed(2));
};
height.addEventListener("input", calculateWidth);
width.addEventListener("input", calculateHeight);
ratioHeight.addEventListener("input", calculateHeight);
ratioWidth.addEventListener("input", calculateHeight);
728x90
LIST
'HTML _CSS' 카테고리의 다른 글
CSS Tricky Shape (0) | 2022.12.03 |
---|---|
Input Label Animation (0) | 2022.11.28 |
Liquid Drop Login page (0) | 2022.11.26 |
Rotating border (0) | 2022.11.23 |
Postage Stamp Cutout (0) | 2022.11.22 |