REACT
[React] 컴포넌트 활용하기_헤더와 풋터 만들기
쫑나리
2023. 9. 14. 15:44
728x90
반응형
SMALL
위쪽 헤더부분을 컴포넌트로 만들어서
App.js 혹은 원하는 페이지에서 import 하여 이렇게 간편하게 사용 할 수 있습니다.
header
import React from 'react';
import './style.css';
export default function Header() {
return (
<div className='header'>
<header className='headerObj'>
<h1 className='logo'>LOGO</h1>
<nav>
<ul className='nav-links'>
<li><a href='/'>Home</a></li>
<li><a href='/about'>About</a></li>
<li><a href='/contact'>Contact</a></li>
</ul>
</nav>
</header>
</div>
);
}
.header {
background-color: #020202;
display: flex;
justify-content: center;
}
.headerObj {
display: flex;
justify-content: space-between;
padding: 0;
width: 90%;
text-align: center;
margin: 0;
}
a {
text-decoration: none;
color: #fff;
font-size: 1.2rem;
}
.logo {
font-size: 24px;
}
.nav-links {
list-style-type: none;
}
.nav-links li {
display: inline-block;
margin-left: 4rem;
}
footer
import React from 'react';
import './style.css';
function Footer({ company, email }) {
return (
<footer className='footer'>
<div className="footer-links">
<p>Company : {company} | E-mail : {email} </p>
<p>Copyright © 2023 Company Name</p>
</div>
</footer>
);
}
export default Footer;
.footer {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
background-color: #020202;
color: rgb(255, 255, 255);
padding: 0rem 3rem;
}
.footer-links {
text-align: left;
}
App.js
728x90
반응형
LIST