1-1 ) alpha
<html code>
<section>
<div id="rgba">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime, ut
exercitationem.
</div>
</section>
<css code>
section {
width: 200px;
height: 200px;
background-color: indianred;
}
#rgba {
width: 50%;
height: 50%;
background-color: rgba(255, 255, 255, 0.6);
}
1-2) opacity
'1' 은 전혀 투명하지 X
'0' 은 완전히 투명 O
<html code>
<section>
<div id="opacity">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Maxime, ut
exercitationem.
</div>
</section>
<css code>
#opacity {
width: 50%;
height: 50%;
background-color: yellow;
opacity: 0.4;
}
<body>
<h1>Position Property</h1>
<section id="static">
<h2>Static</h2>
<div></div>
<div id="middle"></div>
<div></div>
</section>
<section id="relative">
<h2>Relative</h2>
<div></div>
<div id="middle"></div>
<div></div>
</section>
<section id="absolute">
<h2>Absolute</h2>
<div></div>
<div id="middle"></div>
<div></div>
</section>
</body>
1) static
div {
width: 100px;
height: 100px;
background-color: cornflowerblue;
margin: 10px;
border: 2px solid black;
display: inline-block;
}
#middle {
background-color: skyblue;
}
#static #middle {
position: static;
top: 100px;
}
2) relative
#relative #middle {
position: relative;
top: 100px;
right: 30px;
left: 30px;
}
3) absolute
#absolute {
position: relative;
}
#aboslute #middle {
position: absolute;
top: 50px;
left: 50px;
}
abosolute 같은경우에는 부모클래스가 'relative'라고 설정을 해줘야 부모클래스 구역 안에서 컨트롤이 가능하다.
4) fixed
1) hover + transition
<html code>
<body>
<h1>Transitions</h1>
<div class="circle"></div>
</body>
<css code>
.circle {
width: 300px;
height: 300px;
background-color: magenta;
transition: 2s;
}
.circle:hover {
background-color: cyan;
border-radius: 50%;
}
<여러가지 조건들>
transition: background-color 0.5s 0.5s;
-> 처음 0.5s : 0.5초동안 변함
두번째 0.5 : hover 하고 0.5초 뒤에 transition 시작 (dealy 시간)
transition: all 0.5s 0.5
-> 모든 특성이 0.5초동안 아무일없다가 0.5초동안 변함.
transition: background-color 0.5s, border-radius 2s;
-> 배경색은 0.5초내로 변하지만 네모에서 원의 형태는 2s에걸쳐 변함.
2) timing
<html code>
<body>
<h1>Transitions</h1>
<div class="circle"></div>
<section>
<div></div>
<div></div>
<div></div>
<div></div>
</section>
</body>
<css code>
section div {
height: 100px;
width: 100px;
background-color: turquoise;
margin: 20px 0;
transition: margin-left 3s;
}
section:hover div {
margin-left: 500px;
}
div:nth-of-type(1) {
transition-timing-function: ease-in;
}
div:nth-of-type(2) {
transition-timing-function: ease-in-out;
}
div:nth-of-type(3) {
transition-timing-function: cubic-bezier(0.7, 0, 0.84, 0);
}
div:nth-of-type(4) {
transition-timing-function: cubic-bezier(0.85, 0, 0.15, 1);
}
-> 모든 사각형에 3초의 전환을 margin-left로 주되 타이밍 기능을 '개별적'으로 지정.
<정리>
1) 애니메이션 효과를 줄 특성지정
2) 지속시간 지정
3) 타이밍기능 지정 (ex) ease-in-out , ease-in)
4) 주로 hover와 함께 쓰임.
transform
<html code>
<body>
<section>
<h1>Transform me !</h1>
<h1>Transform me !</h1>
<h1>Transform me !</h1>
<h1>Transform me !</h1>
</section>
<section>
<h1>Transform me !</h1>
<h1>Transform me !</h1>
<h1>Transform me !</h1>
<h1>Transform me !</h1>
</section>
</body>
<css code>
h1 {
background-color: #2a9d8f;
border: 5px solid black;
color: bisque;
padding: 0.4em;
width: 300px;
font-size: 1.8em;
text-align: center;
margin: 20px auto;
font-family: "Courier New", Courier, monospace;
font-weight: lighter;
}
h1:nth-of-type(2n) {
background-color: #e9c46a;
}
h1:nth-of-type(3n) {
background-color: #f4a261;
}
h1:nth-of-type(4n) {
background-color: blueviolet;
}
section:first-of-type h1:nth-of-type(1) {
/* transform-origin: bottom top ;*/
transform: rotate(45deg);
}
section:first-of-type h1:nth-of-type(2) {
transform: scale(0.8);
}
section:first-of-type h1:nth-of-type(3) {
transform: translateX(200px);
}
section:first-of-type h1:nth-of-type(4) {
transform: translate(-100px, 50px);
}
section:nth-of-type(2) h1:nth-of-type(1) {
transform: skew(30deg);
}
section:nth-of-type(2) h1:nth-of-type(2) {
transform: skew(10deg, 5deg);
}
section:nth-of-type(2) h1:nth-of-type(3) {
transform: rotate(30deg) scale(0.7);
}
section:nth-of-type(2) h1:nth-of-type(4) {
transform: translateX(-500px) rotate(180deg) scaleY(1.5);
}
section:nth-of-type(2) {
transform: scale(0.7);
}
body {
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background-color: #151b29;
}
button {
background: none;
color: #ffa260;
border: 2px solid;
padding: 1em 2em;
font-size: 1em;
transition: color 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
button:hover {
border-color: #f1ff5c;
color: white;
box-shadow: (0 0.5em 0.5em -0.4em);
transform: translateY(-0.25em);
cursor: pointer;
}
section {
width: 80%;
height: 500px;
margin: 0 auto;
background-image: url("https://images.unsplash.com/photo-1657002774608-5f1914825a5c?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1740&q=80");
background-size: cover;
background-position: bottom;
* background 속기법
background: center/cover (사진의 중앙부분을 쓰고싶으면서 반복되는게 싫어서 cover속성을 주고싶으면 '/' 로 연결해야함)
url("https://images.unsplash.com/photo-1657002774608-5f1914825a5c?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1740&q=80");
}
h1 {
font-size: 100px;
color: black;
}
---> head태그에 자손으로서 글꼴 링크 추가
<link
href="https://fonts.googleapis.com/css2?family=Montserrat&display=swap"
rel="stylesheet"
/>
--------------------------------------------------------------------
<body>
<main>
<h1>Google Fonts</h1>
<h2>Subheading Goes Here</h2>
<h3>Chicken Nugget Smoothies</h3>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Commodi
deleniti dolorem impedit facere magni recusandae sint similique minima
non, et, iste dolorum iusto voluptatum? Reprehenderit tempora enim saepe
ipsam dolorum. Fugiat dolorum est accusamus voluptate nam? Ut asperiores
beatae vel quod id. Repudiandae, cupiditate ad. Recusandae sit corporis,
ipsum vero magnam quisquam. Nulla, obcaecati. Quaerat iste dignissimos
id libero quae! Pariatur recusandae laborum animi quas hic error est
nostrum autem ab, in quidem cumque corrupti quos illum maiores sint
provident, sed quia. Quos rerum fugit esse accusantium sapiente
voluptatibus fugiat? Maiores, deserunt praesentium. Dolorem vel
temporibus amet eligendi nisi! Laboriosam nesciunt beatae at nisi
impedit, corporis doloribus hic ex blanditiis et delectus veritatis,
asperiores nobis enim mollitia earum atque. Odit? In aperiam iste beatae
maxime tempore rem accusantium ex corporis. Illo a nobis quis architecto
reprehenderit voluptate ipsum enim beatae saepe consequatur. Rem ex
dolorem ratione quaerat, numquam eligendi itaque. Temporibus placeat
quidem excepturi magni, nostrum quis vel pariatur odio fugit beatae
repellat iure impedit deleniti cumque maxime totam ratione reprehenderit
animi necessitatibus ut illo amet alias! Sapiente, nobis placeat!
</p>
</main>
</body>
<css code>
body {
font-family: "Montserrat", sans-serif;
}
main {
width: 60%;
margin: 0 auto;
}
h1 {
font-size: 3rem;
margin-bottom: 0;
}
h1 + h2 {
margin-top: 10px;
}
h1,
h2,
h3 {
font-family: Roboto, sans-serif;
font-weight: 100;
}
<html code>
<!DOCTYPE html>
<html>
<head>
<title>Photo Blog</title>
<link rel="stylesheet" href="style2.css" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Montserrat&family=Raleway:wght@800&display=swap"
rel="stylesheet"
/>
</head>
<body>
<!-- PUT YOUR NAME HERE! -->
<nav>Jin Cheol</nav>
<!-- Massimo Margagnoni -->
<img
src="http://c1.staticflickr.com/9/8450/8026519634_f33f3724ea_b.jpg"
/><img
src="http://c2.staticflickr.com/8/7218/7209301894_c99d3a33c2_h.jpg"
/><img
src="http://c2.staticflickr.com/8/7231/6947093326_df216540ff_b.jpg"
/>
<!-- Giuseppe Milo -->
<img
src="http://c1.staticflickr.com/9/8788/17367410309_78abb9e5b6_b.jpg"
/><img
src="http://c2.staticflickr.com/6/5814/20700286354_762c19bd3b_b.jpg"
/><img
src="http://c2.staticflickr.com/6/5647/21137202535_404bf25729_b.jpg"
/>
<!-- GörlitzPhotography -->
<img
src="http://c2.staticflickr.com/6/5588/14991687545_5c8e1a2e86_b.jpg"
/><img
src="http://c2.staticflickr.com/4/3888/14878097108_5997041006_b.jpg"
/><img
src="http://c2.staticflickr.com/8/7579/15482110477_0b0e9e5421_b.jpg"
/>
<!-- All Photos Licensed Under Creative Commons 2.0 -->
<!-- https://creativecommons.org/licenses/by/2.0/legalcode -->
</body>
</html>
<css code>
img {
width: 30%;
margin: calc(10% / 6);
/* margin: 1.6666%: 이미지 너비가 30씩 차지했으므로 나머지 10프로의 여백을 하나의 사진당 좌,우에 배당한다고 했을 때 10/6의 값. */
}
nav {
text-transform: uppercase;
border-bottom: 2px solid #f1f1f1;
width: 30%;
margin-left: calc(10% / 6);
padding: 20px 0;
font-size: 1.5em;
font-family: "Raleway", sans-serif;
padding: 1.2em 0;
}
<html code>
<body>
<h1>Let's Play With Flexbox</h1>
<section id="container">
<div style="background-color: #80ffdb"></div>
<div style="background-color: #64dfdf"></div>
<div style="background-color: #48bfe3"></div>
<div style="background-color: #5390d9"></div>
<div style="background-color: #6930c3"></div>
</section>
</body>
<css code>
body {
font-family: "Open Sans", sans-serif;
}
h1 {
text-align: center;
}
#container {
background-color: cadetblue;
width: 90%;
height: 400px;
margin: 0 auto;
border: 5px solid #003049;
display: flex;
}
#container div {
width: 100px;
height: 100px;
}
display:flex 적용 전
적용 후
flex-direction: row-reverse;
flex-direction: column;
flex-direction: column-reverse;
display: flex;
flex-direction: row;
justify-content: flex-start;
display: flex;
flex-direction: row;
justify-content: flex-end;
display: flex;
flex-direction: row;
justify-content: center;
display: flex;
flex-direction: row;
justify-content: space-between;
display: flex;
flex-direction: row;
justify-content: space-around;
display: flex;
flex-direction: row;
justify-content: space-evenly;
- justify-content 는 특정한 수평,수직이 아니다.
flex-direction에 따라 방향과 주축이 달라진다.
(상->하 , 하->상 , 좌->우 , 우->좌)
flex-direction: column;
justify-content: space-evenly;
flex-wrap: wrap;
flex-direction: column;
justify-content: space-evenly;
flex-wrap: wrap-reverse;
<html code>
<body>
<h1>Let's Play With Flexbox</h1>
<section id="container">
<div style="background-color: #80ffdb">H</div>
<div style="background-color: #64dfdf">E</div>
<div style="background-color: #48bfe3; height: 200px">L</div>
<div style="background-color: #5390d9">L</div>
<div style="background-color: #6930c3; height: 50px">O</div>
</section>
</body>
<css code>
#container {
background-color: cadetblue;
width: 90%;
height: 200px;
margin: 0 auto;
border: 5px solid #003049;
display: flex;
flex-direction: row;
justify-content: center;
align-items: baseline;
}
#container div {
width: 100px;
height: 100px;
font-size: 2em;
}
#container {
background-color: cadetblue;
width: 90%;
height: 350px;
margin: 0 auto;
border: 5px solid #003049;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
flex-wrap: wrap;
}
#container div {
width: 140px;
height: 140px;
text-align: center;
}
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-end;
flex-wrap: wrap;
align-content: center;
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
flex-wrap: wrap;
align-content: space-between;
#container {
display: flex;
flex-direction: row;
justify-content: center;
align-items: flex-start;
flex-wrap: wrap;
}
div:nth-of-type(3) {
align-self: flex-end;
}
div:nth-of-type(2) {
align-self: center;
}
div:nth-of-type(3) {
align-self: flex-end;
}
1) flex-basis
#container {
background-color: cadetblue;
width: 90%;
/*height: 200px; */
margin: 0 auto;
border: 5px solid #003049;
display: flex;
flex-direction: row;
justify-content: center;
}
#container div {
width: 100px;
height: 100px;
text-align: center;
flex-basis: 400px;
}
#container div {
width: 100px;
height: 50px;
flex-basis: 100px;
}
2) flex-grow
#container {
background-color: cadetblue;
width: 90%;
/*height: 200px; */
margin: 0 auto;
border: 5px solid #003049;
display: flex;
flex-direction: row;
justify-content: center;
}
#container div {
width: 100px;
height: 100px;
text-align: center;
flex-basis: 100px;
}
div:nth-of-type(1) {
flex-grow: 1;
}
3) flex-shrink
#container {
background-color: cadetblue;
width: 90%;
/*height: 200px; */
margin: 0 auto;
border: 5px solid #003049;
display: flex;
flex-direction: row;
justify-content: center;
}
#container div {
width: 100px;
height: 100px;
text-align: center;
flex-basis: 100px;
}
div:nth-of-type(1) {
flex-grow: 1;
flex-shrink: 2;
}
div:nth-of-type(5) {
flex-grow: 2;
}
flex : (flex-grow | flex-shrink | flex-basis) ->가장많이씀.
flex : (flex-grow | flex-shrink)
if flex's one of the elements is px or em
flex : (flex-grow | flex-basis)
<html code>
<body>
<h1>Let's Play With Flexbox</h1>
<section id="container">
<div style="background-color: #80ffdb"></div>
<div style="background-color: #64dfdf"></div>
<div style="background-color: #48bfe3"></div>
<div style="background-color: #5390d9"></div>
<div style="background-color: #6930c3"></div>
</section>
<h2>Another Exmaple</h2>
<main>
<section class="sidebar"></section>
<section class="maincontent"></section>
<section class="sidebar"></section>
</main>
</body>
<css code>
main {
width: 80%;
margin: 0 auto;
border: 5px solid black;
height: 300px;
display: flex;
}
main .sidebar {
background-color: purple;
border: 2px solid white;
flex: 1 2;
}
main .maincontent {
background-color: green;
flex: 2 1 400px;
}
<html code>
<body>
<nav>
<a href="#home">Home</a>
<ul>
<li>
<a href="#Home">Learn More</a>
</li>
<li>
<a href="#Home">About</a>
</li>
<li>
<a href="#Home">Contact</a>
</li>
</ul>
<a href="#signup">Sign Up</a>
</nav>
<h1>Media Queries</h1>
</body>
<css code>
body {
font-family: "Open Sans", sans-serif;
}
h1 {
font-size: 6em;
text-align: center;
}
nav {
font-size: 1.5em;
display: flex;
justify-content: space-between;
}
ul,
li {
display: inline;
margin: 0;
padding: 0;
}
ul {
flex: 1;
max-width: 50%;
display: flex;
justify-content: space-evenly;
}
h1 {
color: red;
}
@media (min-width: 500px) {
h1 {
color: orange;
}
}
@media (min-width: 1000px) {
h1 {
color: yellow;
}
}
@media (min-width: 1500px) {
h1 {
color: green;
}
}
@media (max-width: 768px) {
h1 {
font-size: 4em;
}
nav,
nav ul {
flex-direction: column;
align-items: center;
}
}
@media (max-width: 576px) {
h1 {
font-size: 3em;
}
}