- 인라인 요소

 

    크기값 x 
    한줄에 여러개 배치
    상하마진 못가짐
    기본 너비값은 컨텐츠의 너비값

<head>
    <style>
        span {
            border: 1px solid #000;
            width: 100px;
            height: 100px;
            margin: 20px;
        }
    </style>
</head>
<body>
	<div>1. inline</div>    
    <span>Inline</span>
    <span>Inline2 </span>
</body>

크기값x 좌우마진만 갖는다.

 

 

- 블럭 요소

 

    크기값 o

    한줄에 한개만 배치

    상하좌우 마진 가짐

    기본 너비값 100%

 

div {

    width: 100%;

이렇게 기본 너비값을 써줄 필요가 없음!

}

<head>
    <style>
       .block {
            border: 1px solid red;
            width: 100px;
            height: 100px;
            margin: 20px;
        }
    </style>
</head>
<body>
    <div>2. block</div>
    <div class="block">Block</div>
    <div class="block">Block2</div>
</body>

 

 

- 인라인 블럭

크기값 o

한줄에 여러개 배치

상하좌우 마진 가짐

기본 너비값은 컨텐츠의 너비값 

img, input, button, fontawesome icon 

 

h1은 block요소이지만 display: inline-block으로 바꿔서 img옆에 붙게 된다.

<head>
    <style>
        img {
            margin: 20px;
            width: 300px;
            height: 300px;
        }
        h1 {
            border: 1px solid blue;
            display: inline-block;
        }
    </style>
</head>
<body>
    <img src="img/face-02.jpg" alt="">
    <img src="img/face-02.jpg" alt="">
    <h1>block elements</h1>
</body>

 

- 포지션 

position: static; // 기본값

어떤 요소이건 positionabsolute; fixed; 가 들어가면 모든 요소는 인라인 블럭으로 바뀐다.

position: absolute;

/* display: inline-block; 의미가 없음, absolute면 인라인블럭이 된다. */ 

css js연결 방법

    <style></style>   html 내부 스타일

    <script></script> 내부 스크립트

 

    외부에서 불러올 때

    <link rel="stylesheet" href="style.css">

    <script src="custom.js"></script>

 

    <h1 style="color:red;"></h1> 인라인 스타일

    <h1 onclick="window.close()"></h1> 인라인 자바스크립트

 

- onclick javascript event

- 현재 탭에서 열기 

section 클릭 시 html로 연결된다.

<section onclick="location.href='iphonex.html'"></section>

<div class="wrap">
        <header>
            <nav>
                <div class="navi">
                    <a href="">icon</a>
                    <a href="">Mac</a>
                    <a href="">iPad</a>
                    <a href="">Watch</a>
                    <a href="">Music</a>
                    <a href="">고객지원</a>
                    <a href="" class="btn-search">검색</a>
                    <a href="" class="btn-search">장바구니</a>
                </div>
            </nav>
        </header>

        <section 
            class="welcome" 
            onclick="location.href='iphonex.html'">
            <div class="heading">
                <h3>iPhone</h3>
                <a href="iphonex.html">Encounter with the future</a>
            </div>
        </section>
</div>

.html 말고 url도 가능하다. "" 안에 "" 로 쓰면 안되고 작은따옴표로 써야한다. 

 

 

- 새탭에서 열기 

<section onclick="window.open( '링크' )"></section>

        <!-- 새창으로 띄우기 -->
        <section class="welcome"
            onclick="window.open('iphonex.html')">
            <div class="heading">
                <h3>iPhone X</h3>
                <a href="iphonex.html">Encounter with the future</a>
            </div>
        </section>

 

 

<a>

   <section></section>

</a>

a태그로 감싸는 방법은 비추천이다.

 

 

- 인접선택자 + : 바로 밑 요소 (자기보다 위의 요소는 x)

    1. ul + p 
    <ul>
        <li>목록1</li>
        <li>목록2</li>
        <li>목록3</li>
    </ul>
    <p>문단입니다.</p>
    <p>문단입니다.</p>
ul + p {
    color: hotpink;
}

ul의 바로 밑 p만 색이 변한다.

 

 

- 형제선택자 ~ : 형제요소만 선택 

ul ~ p

ul 밑에 형제p만 선택된다.

    2. ul ~ p 
    <ul>
        <li>목록1</li>
        <li>목록2</li>
        <li>목록3</li>
    </ul>
    <p>문단입니다.</p>
    <p>문단입니다.</p>
    <div>
        <p>문단입니다.</p>
    </div>
ul ~ p {
    color: blue;
}

 

- 햄버거 버튼 클릭시 엑스 

input:checked (클릭 시) label 디자인 

    <!-- 햄버거 버튼 , 사이드 바  -->
    <div class="inner">
        <input type="checkbox" id="trigger">
        <label for="trigger">
            <span></span>
            <span></span>
            <span></span>
        </label>
        <div class="sidebar"></div>
    </div>

 

.inner {}
.inner input[id="trigger"] {
    display: none;
}

/* 버튼 클릭 시 엑스모양 */
.inner input[id="trigger"]:checked + label span:nth-child(1) {
    top: 50%;
    transform: rotate(45deg);
}
.inner input[id="trigger"]:checked + label span:nth-child(2) {
    opacity: 0;
}
.inner input[id="trigger"]:checked + label span:nth-child(3) {
    top: 50%;
    transform: rotate(-45deg);
}

/* 버튼 클릭 -> 사이드바 left-250에서 0으로 나타나게 */
.inner input[id="trigger"]:checked ~ .sidebar {
    left: 0;
}
/* 버튼 클릭 -> 
엑스 위치 조절하기위해서 라벨을 relative에서 absolute로 변경 */
.inner input[id="trigger"]:checked + label {
    left: 210px; 
}
label[for="trigger"] {
    position: absolute;
    top: 20px;
    left: 10px;    
    display: inline-block;
    width: 30px;
    height: 20px;
    cursor: pointer;
    transition: 0.3s;
    /* border: 1px solid #000; */
}

/* 햄버거버튼 */
label[for="trigger"] span {
    position: absolute;
    display: block;
    width: 100%;
    height: 2px;
    left: 0;
    background-color: #000;
    transition: 0.3s;
    z-index: 1;
}
label[for="trigger"] span:nth-child(1) {
    top: 0;
}
label[for="trigger"] span:nth-child(2) {
    top: 50%;
}
label[for="trigger"] span:nth-child(3) {
    top: 100%;
}

.sidebar {
    position: fixed;
    top: 0;
    left: -250px;
    width: 250px;
    height: 100vh;
    background-color: pink;
    transition: 0.3s;
}

'Web > HTML CSS 퍼블리싱' 카테고리의 다른 글

폰트사이즈 em, rem 정리  (0) 2022.02.07
display 속성의 이해 (인라인, 인라인블록, 블록)  (0) 2022.02.03
iframe, a target속성  (0) 2021.07.22
앵커 (anchor) 만들기  (0) 2021.07.22
login form #2  (0) 2021.07.21

iframe : html body안에서 또다른 html이나 url을 불러와 심는 것이다.

src안에는 .html .com .jpg .txt등 웹브라우저가 보여줄 수 있는 파일 확장자는 다 가능하다.

    <iframe src="test.html"></iframe>

 

   // test.html
    <h1>Test page</h1>
    <a href="https://www.Inflearn.com" 
    	target="_parent">인프런 홈페이지 바로가기</a>

   

target="_self" : 기본값, 자기자신의 창에서 열기

target="_blank" : 새창 열기

target="_parent" : 프레임을 무시하고 부모위치에서 띄운다. 

 

 

 

- 앵커 (anchor) : 한 페이지 안에서 지정된 위치로 점프하여 스크롤

 

a태그를 클릭하면 위치로 점프 

    <a href="#앵커이름"></a>

    <태그이름 id="앵커이름"></> 

smooth scrolling

1. html { scroll-behavior: smooth; }

2. jquery scrollTo 플러그인 이용 

 

 

 

    <div class="container">
        <header>
            <!-- <a href="#none"><img src="img/naverband/logo-band.png" alt=""></a> -->
            <a href="#part1">html part</a>
            <a href="#part2">css part</a>
            <a href="#part3">jquery part</a>
            <a href="#part4">portfolio part</a>
        </header>  
        <h1 id="part1">html part</h1>
        <hr>
        <p>
            lorem200
        </p>
        <a href="#" class="btn-gototop">Go to top</a>
        
        <h1 id="part2">css part</h1>
        <hr>
        <p>
            lorem200
        </p>
        <a href="#" class="btn-gototop">Go to top</a>
        <h1 id="part3">jquery part</h1>
        <hr>
        <p>
            lorem200
        </p>
        <a href="#" class="btn-gototop">Go to top</a>
        <h1 id="part4">portfolio part</h1>
        <hr>
        <p>
            lorem200
        </p>
        <a href="#" class="btn-gototop">Go to top</a>
html {
    /* IE는 안됨 */
    scroll-behavior: smooth;
}
body {
    /* font-family: 'Raleway', 'sans-serif'; */
    /* font-family: 'Noto Sans KR', 'sans-serif'; */
    font-family: 'Montserrat', sans-serif;

    margin: 0;
    line-height: 1.5em;
    background-color: #eee;
    color: #222;
}
a {
    text-decoration: none;
    color: #000;
}
ul {
    list-style: none;
}
.container {
    margin: 20px;
}
header {

}
header a {
    padding: 10px 20px;
    background-color: teal;
    color: #fff;
    text-transform: uppercase;
}
.container p {
    font-size: 1.5em;
    line-height: 2em;
}
.btn-gototop {
    padding: 10px 20px;
    background-color: pink;
    color: #fff;
    border-radius: 20px;
}

 

 

 - jquery scrollTo 플러그인 이용 

<head>
    <title>Document</title>
    <script src="script/jquery-3.4.1.min.js"></script>
    <script src="script/jquery.scrollTo.min.js"></script>
</head>
<body>


    <!-- Smooth Scroll -->
    <script>
        $('header a, .btn-gototop').click(function() {
            // 0.9s
            $.scrollTo(this.hash || 0, 900);
            e.prventDefault();
        });
    </script>
    <!-- Smooth Scroll -->
</body>

 

 

jquery.scrollTo.min.js
0.00MB
jquery-3.4.1.min.js
0.08MB

'Web > HTML CSS 퍼블리싱' 카테고리의 다른 글

Hamburger Menu (+, ~ 선택자 이용)  (0) 2021.07.22
iframe, a target속성  (0) 2021.07.22
login form #2  (0) 2021.07.21
크롬 확장 프로그램 추천  (0) 2021.07.20
login form #1  (0) 2021.07.08

 

a*3 - 폰트어썸 유니코드 사용

버튼 백그라운드 linear-gradient()

그라디언트 참고 사이트 : https://webgradients.com/

 

Free Gradients Collection by itmeo.com

Free collection of 180 background gradients that you can use as content backdrops in any part of your website.

webgradients.com

 

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
29
30
31
32
33
34
35
36
37
<div class="container">
    <section>
            <div class="login">
                <div class="login-header">
                    <h1>Log in</h1>
                    <span></span>
                </div>
                <div class="login-type-sns">
                    <a class="sns" href="#none"></a>
                    <a class="sns" href="#none"></a>
                    <a class="sns" href="#none"></a>
                    <span class="or-text">or use your email</span>
                </div>
                <div class="login-email">
                    <label for="email-chk">Email</label>
                    <input type="email" id="email-chk" placeholder="Email"> 
                    <label for="pw-chk">Password</label>
                    <input type="password" id="pw-chk" placeholder="Password">
                </div>
                <div class="login-footer">
                    <div class="forgot-pw">
                      <input class="left" type="checkbox" id="keep-login"> 
                       <label for="keep-login">Remember Me</label>
                      <a class="right" href="#none">Forgot Password?</a>
                    </div>
 
                    <div class="btn">Submit</div>
                    <div class="terms">
                        <a class="left" href="#none">Privacy Policy</a>
                        <a class="right" href="#none">Terms & Conditions</a>
                    </div>
                    
                </div>
            </div>
    </section>        
</div>
 
cs
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
 
148
149
150
151
152
153
154
155
156
157
158
159
160
/* Google Web Font */
@import 
url('https://fonts.googleapis.com/
css2?family=Raleway:wght@300;500&display=swap'
);
/* 폰트어썸 4.7 */
@import 
url('https://stackpath.bootstrapcdn.com/
font-awesome/4.7.0/css/font-awesome.min.css'
);
/* default css */
/* 폰트 기본값 : 16px = 1em = 100% = 12pt */
body {
    font-family: 'Raleway', 'sans-serif';
    margin: 0;
    line-height: 1.5em;
    background-color: #eee;
    color: #222;
}
{
    text-decoration: none;
    color: #000;
}
h1 {
    margin: 0;
}
section {
    position: relative;
    height: 100vh;
    border: 1px solid #000;
}
.login {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 480px;
    height: 670px;
    background-color: #fff;
    border-radius: 20px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.363);
}
.login-header {
    margin-top: 80px;
    text-align: center;
    /* border: 1px solid #000; */
}
.login-header:hover span {
    width: 120px;
}
.login-header h1 {
    margin: 15px 0;
    font-size: 35px;
}
.login-header span {
    display: inline-block;
    width: 45px;
    height: 6px;
    background: linear-gradient(to left, #7028e4 0%, #e5b2ca 100%);
    transition: 0.3s;
}
.login-type-sns {
    margin-top: 5px;
    /* border: 1px solid blue; */
    text-align: center;
}
.sns {
    margin: 5px 0;
    margin-right: 5px;
    display: inline-block;
    width: 45px;
    height: 45px;
    border: 1px solid lightgray;
    border-radius: 50%;
    box-shadow: 0 4px 5px rgba(0, 0, 0, 0.226);
}
.sns:before {
    content: '\f09a';
    font-family: fontawesome;
    line-height: 45px;
    font-size: 20px;
}
.sns:nth-child(1):before {
    content: '\f09a';
}
.sns:nth-child(2):before {
    content: '\f0e1';
}
.sns:nth-child(3):before {
    content: '\f099';
}
.or-text {
    display: block;
    margin: 10px 0;
    font-size: 14px;
}
.login-email {
    padding: 0 60px;
}
.login-email input {
    display: block;
    padding: 20px;
    margin: 10px;
    width: 85%;
    border: 1px solid rgba(211, 211, 211, 0.712);
    border-radius: 15px;
    outline: none;
}
.login-email input:focus {
    border: 1px solid #7028e4;
}
.login-email input::placeholder {
    color: lightgray;
}
.login-email label {
    font-size: 14px;
    font-weight: bold;
}
.login-footer {
    padding: 0 60px;
}
.forgot-pw {
    overflow: hidden;
    font-weight: bold;
    padding: 10px;
    font-size: 14px;
}
.forgot-pw input {
    margin-top: 5px;
}
.forgot-pw label[for=keep-login] {
    margin-left: 5px;
    letter-spacing: .5px;
}
.forgot-pw a:hover {
    text-decoration: underline;
}
.left {
    float: left;
}
.right {
    float: right;
}
.btn {
    padding: 15px;
    margin: 10px;
    width: 85%;
    background: linear-gradient(to left, #7028e4 0%, #e5b2ca 100%);
    color: #fff;
    font-size: 20px;
    /* border: 1px solid transparent; */
    border-radius: 50px;
    box-shadow: 0 5px 20px #7028e449;
    text-align: center;
    cursor: pointer;
}
.terms {
    overflow: hidden;
}
.terms a {
    margin-top: 20px;
    font-weight: bold;
    font-size: 14px;
}
cs

'Web > HTML CSS 퍼블리싱' 카테고리의 다른 글

iframe, a target속성  (0) 2021.07.22
앵커 (anchor) 만들기  (0) 2021.07.22
크롬 확장 프로그램 추천  (0) 2021.07.20
login form #1  (0) 2021.07.08
full screen 검색창  (0) 2021.07.06

+ Recent posts