๊ธฐ๋ณธ ์คํ : react
์ฌ๊ฑด์ ์ ๋ง
์ด ํฌ์คํ ์ ์ํ๋ ๋งํฌ์ ์ ์ํด ์ข์ถฉ์ฐ๋ css๋ฅผ ๋ง์ก๋ ๊ณผ์ ์ ๋ด์ ์์ ๊ธฐ์ด๋ค.
๋์๋ณ ํ์ฌ ๋ ์จ ์ ๋ณด ์ฑํ์ด์ง๋ฅผ ๋ง๋๋ ๊ณผ์ ์ค์ div ๋ฐ์ค๋ฅผ ์ ์ ํ ์์น๋ก ๋ด๋ฆฌ๊ณ ์ถ์๋ค.
CSS position
[css] position ์์์ ์์น ์ค์
CSS / POSITION position ํน์ง ์์์ ์์น๋ฅผ ๋ง์๋๋ก ์ค์ ํ๊ธฐ ์ํ ์์ฑ static, relative, absolute, fixed, sticky๋ก position์ ๊ฐ์ ์ค ์ ์๋ค. ์์น๋ฅผ ์ค์ ํ ๋์๋ top,right,left,bottom์ ์ฌ์ฉํ ์ ์๋ค. ์์
itjy2.tistory.com
์ ํฌ์คํ ์ ์ฐธ๊ณ ํ์ฌ, div๋ฅผ ์ํ๋ ์์น์ ์ฎ๊ฒจ๋ณด์๋ค.
.container{
position:relative;
/*์๋ ์์ด์ผ ํ ์์น์์ ์์์๋ถํฐ 100px ๋จ์ด์ง๋ค*/
top:100px;
}
ํ์ฌ ์น ํฌ๊ธฐ์ ๋ง๊ฒ div๊ฐ ๋ด๋ ค๊ฐ๊ธฐ๋ ํ์์ง๋ง, ์นํ์ด์ง๋ฅผ ์ค์๋ค ๋๋ ธ๋ค(๊ฐ๋ก๋ก, ์ธ๋ก๋ก๋) ํ์ ๋
ํ ํ๋ฉด ์์ ์๋ ์์๋ค์ ๋น์จ์ด ์ด์ํ๊ฒ ๋ณ๊ฒฝ๋จ + ํ๋ ๋ฒํผ๋ค์ด ํ๋ฉด ์๋๋ก ๋ฐ๋ ค๋๊ฐ + ๋ฐฐ๊ฒฝ ์ฌ์ง์ด full ์ด ์๋๋ผ ์๋ ํฐ์ ๊ณต๋ฐฑ์ด ์๊น ; ์ด์๊ฐ ๋ฐ์ํ์๋ค.
์๋ง ์๋์ ๊ฐ์ด ๋ ์จ info ๋ฐ์ค์ ํด๋์ค์ top:100px; ์์ฑ์ ์ฃผ์ด์ ์ ๋จผ ๋ธ๋ฃจ ๋ฒํผ ๊ทธ๋ฃน์ด ๋ฐ๋ ค๋ด๋ ค๊ฐ ๊ฒ ๊ฐ์๋ค.
๋ฐ์ํ ๋ฐฐ๊ฒฝ์ด๋ฏธ์ง
์ผ๋จ ์น์ ์ฌ์ด์ฆ๋ฅผ ์ค์์ ๋ ๋ฐฐ๊ฒฝ์ฌ์ง์ด
๋ฐ์ํ ์น๊ณผ ๊ฐ์ด ์์ ํ ๋ณํํ์ง ์๋๋ค๋ฉด ์ ์ ์๊ฒ ๋์ด ์์น๋ฅผ ๋๋ ค๋ณด๊ฒ ๋์๋ค.
๋ฐ์ํ์ผ๋ก ์ข ํก๋น ์ ์งํ์ฌ ์ด๋ฏธ์ง ํ์ํ๊ธฐ
๋ฐ์ํ ์น์ ๊ณต๋ถํ๋ฉด์ ` ํ๊ทธ๊ฐ ์๋, ํน์ card์ ๊ฐ์ ์ปดํฌ๋ํธ์ ๊ฐ๋ก ์ธ๋ก ๋น์จ์ ์ ์งํ๋ฉด์ background-image`๋ฅผ ์ฃผ๋ ๋ฐฉ๋ฒ์ ๋ํด์ ์๊ฐ๋๋ฆฌ๋ ค๊ณ ํฉ๋๋ค!
velog.io
background-image
<div> ํ๊ทธ ๋ฑ์ผ๋ก ํฌ๊ธฐ๊ฐ ์๋ ์ปจํ ์ด๋์ ๋ํด์ background-image ์์ฑ์ ์ฃผ์ด์ ์ปจํ ์ด๋๋ฅผ ํ๋ฉด ์ฌ์ด์ฆ์ ๋ฐ๋ผ ํฌ๊ธฐ๋ฅผ ๋ณ๊ฒฝ์ํค๋ฉฐ ๋ฐ์ํ์ผ๋ก ๊ตฌํํ ์๋ ์์ต๋๋ค.
1๏ธโฃ ์ด๋ฏธ์ง๋ฅผ ๋ธ๋ผ์ฐ์ ์ ํฌ๊ธฐ์ ๋ฐ๋ผ ๊ฝ ์ฑ์ธ ๊ฒฝ์ฐ
.card{
width: 100%;
height: 100vh;
background-image: url("image-url");
background-repeat: no-repeat // background-image๊ฐ ์ปจํ
์ด๋๋ฅผ ๊ฐ๋ ์ฑ์ฐ์ง ๋ชปํ ๊ฒฝ์ฐ์๋ ๋ฐ๋ณตํ์ง ์๋๋ค.
background-size: cover; // ์ฌ์ด์ฆ๊ฐ container์ ๋ง์ง ์์๋ ๊ฝ ์ฐจ๋๋ก ์ฑ์ด๋ค.
background-position: center; // background-image๊ฐ ์ปจํ
์ด๋์ ๊ฐ์ด๋ฐ๋ก ์ค๋๋ก ํ๋ค.
}
๋ฐฐ๊ฒฝ์ด๋ฏธ์ง๋ ์์ ์ ๋ณด๋ฅผ ์ด์ฉํ์ฌ ํ๊ฒฐ ๋ฐ์ํ์ค๋ฌ์์ก๋ค.
ํ ์คํธ ์ค์์ ๋ ฌ
๊ทธ ๋ค์ ๋ ์จ ์ ๋ณด ํ ์คํธ ๋ค์ ์ ๋ถ ์ค์์ ๋ ฌ ์์ผ ์ฃผ์๋ค.
์ฐธ๊ณ : https://biyanbiyan.tistory.com/367
[css] button ํ ์ค๋ก ๊ฐ์ด๋ฐ ์ ๋ ฌ
๋ฒํผ div์ผ๋ ๊ฒ์ ๋ค์ div๋ก ๊ฐ์ธ์ค button1 button2 ๊ทธ๋ฆฌ๊ณ ๊ฒ์ ๊ฐ์ผ div์ width: 100%, text-align: center ์ฃผ๊ณ ๋ฒํผ ๊ฐ์ผ div์ display:inline-block ํ๋ฉด ๋จ.
biyanbiyan.tistory.com
๊ทธ ์ธ์๋ flex๋ฅผ ๋๋ ค๋ง์ผ๋ฉฐ...
์ํ๋ ๋ฐ์ํ ์คํ์ผ์ ๊ตฌ์ถํ ์ ์์๋ค.
์ต์ข
์ ๋ฒ(?) ๊ทผ์ฌํ ๋ฐ์ํ ์น์ด ์์ฑ๋์๋ค.
์ฝ๋ ๊ณต๊ฐ (react ๊ธฐ๋ฐ)
* ์ฐธ๊ณ ๋ก ํ๋ ๋ฒํผ๋ค์ ๋ถํธ์คํธ๋ฉ ์ผ์ต๋๋ค.
App.js
๋งํฌ์ ์ฐธ๊ณ ์ ํ์ํ๋ค ์ถ์ ์ฝ๋๋ค๋ง ๊ธ์ด์ ์ฌ๋ ธ์ต๋๋ค.
์ ์ฒด ์ฝ๋ ๊ถ๊ธํ์ ๋ถ๋ค ๋์์ผ๋ก ๊นํ๋ธ ๋งํฌ ๊ณต์ ํ๊ฒ ์ต๋๋ค.
import './App.css';
import { useEffect, useState } from 'react';
import WeatherBox from "./component/WaetherBox";
import WeatherButton from "./component/WeatherButton";
import 'bootstrap/dist/css/bootstrap.min.css';
function App() {
return (
<div>
<div className='main'>
<WeatherBox />
<div className='cityButtonGroup'>
<WeatherButton title="Seoul" />
<WeatherButton title="NewYork" />
<WeatherButton title="Toronto" />
<WeatherButton title="Paris" />
<WeatherButton title="Rondon" />
</div>
</div>
<div>
</div>
</div >
);
}
export default App;
WeatherBox.js
import React from 'react'
const WaetherBox = () => {
return (
<div className='weather-info-parents'>
<div className='weather-info'>
<div className='weather-info-text'>Your Weather</div>
<h2 className='weather-info-text'>30๋ / 230 ํ์จ</h2>
<h2 className='weather-info-text'>๋ง์ ํ๋</h2>
</div>
</div>
)
}
export default WaetherBox
WeatherButton.js
import React from 'react'
import { Button } from 'react-bootstrap';
const WeatherButton = (props) => {
return (
<div>
<Button variant="primary">{props.title}</Button>
</div>
)
}
export default WeatherButton
App.css
body{
background-image : url(https://wallpaperaccess.com/full/5466320.jpg);
height: 100vh;
width: 100%;
background-repeat: no-repeat;
background-size: cover;
background-position: center;
}
.main{
display: flex;
flex-direction: column;
margin: auto;
justify-content: center;
justify-content: space-evenly;
height: 100vh;
}
.weather-info-parents{
display: flex;
justify-content: center;
}
.weather-info{
width: 500px;
border: 3px solid #aec6fe;
color: white;
padding: 50px;
}
.weather-info-text {
width: 100%;
text-align: center;
}
.cityButtonGroup{
display: flex;
justify-content: center;
justify-content: space-evenly;
align-items: center;
position:relative;
width: 100%;
overflow: hidden;
}
- Happy Ending -
+ .weather-info๋ฅผ ์๋์ ๊ฐ์ด ์กฐ๊ธ ๋ ๋ค๋ฌ์๋ค.
background-color:rgba(0, 0, 0, 0.2);/*๊น๋ง์(0,0,0) 20% ๋ถํฌ๋ช
๋*/
.weather-info{
width: 800px;
border: 3px solid #aec6fe;
border-radius: 10px;
color: white;
background-color:rgba(108, 144, 202, 0.4);
padding: 100px;
}
'๋งํฌ์ > Html & Css' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[HTML & CSS][DOM] CSSStyleDeclaration ์์๋ณด๊ธฐ (0) | 2022.12.23 |
---|---|
[HTML][Canvas] ํ๊ทธ Canvas ์์๋ณด๊ธฐ (0) | 2022.12.23 |
[HTML ์ขํ] x, y, ox, oy, Height, width (0) | 2022.08.26 |
[HTML][CSS] box model (0) | 2022.06.11 |
[CSS] CSS Variable -- (0) | 2022.06.05 |