body 에 백그라운드 이미지 넣고 body:before에 백그라운드 색상을 어두운 색으로 오버레이 

z-index: -1 로 설정해서 input요소 뒤로 감  

 

1
2
3
4
5
    <form action="" class="search">
        <h1>What are you looking for?</h1>
        <input type="text" placeholder="Type...">
        <input type="submit" value="Search">
    </form>
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
body {
    margin: 0;
    line-height: 1.5em;
    font-weight: 300;
 
    background: url(../img/snow-photo.jpg) no-repeat center center;
    /* 브라우저에 가득차게 */
    background-attachment: fixed;
 
    /* background-image: url();
    background-repeat: no-repeat;
    background-position: center center;
   background-attachment: fixed; 와

background: url() no-repeat center center fixed 는 같다 */
}
/* 오버레이 */
body:before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background-color: rgba(0, 0, 0, 0.596);
    z-index: -1;
}
.search {
    /* border: 1px solid #fff; */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
.search h1 {
    color: #fff;
    text-align: center;
    font-weight: normal;
    margin-bottom: 30px;
    font-size: 40px;
}
.search input[type=text],
.search input[type=submit] {
    padding: 20px;
    box-sizing: border-box;
    border: none;
    outline: none;
}
.search input[type=text] {
    width: 350px;
    padding-left: 40px;
    border-radius: 40px 0 0 40px;
    outline: none;
    margin-right: -6px;
}
.search input[type=submit] {
    width: 150px;
    background-color: orange;
    color: #fff;
    border-radius: 0 40px 40px 0;
    cursor: pointer;
}
.search input[type=submit]:hover {
    background-color: darkgoldenrod;    
}
.search input[type=text]::placeholder {
    font-style: italic;
    font-size: 20px;
}
cs

 

 

 

 

- html

container > card*3

 
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
    <div class="container">
        <div class="card">
            <img src="img/crew/crew-01.jpg" alt="">
            <div class="content">
                <h2>
                    Andrew Yu 
                    <span>Developer</span>
                </h2>
                <p>
                    Lorem ipsum dolor sit amet consectetur adipisicing elit. 
                    Excepturi harum aperiam eius ad deserunt sed!
                </p>
                <div class="sns">
                    <a href="#none">
                        <i class="fa fa-facebook"></i>
                    </a>
                    <a href="#none">
                        <i class="fa fa-twitter"></i>
                    </a>
                    <a href="#none">
                        <i class="fa fa-instagram"></i>
                    </a>
                </div>
            </div>
        </div>
        <div class="card">
            <img src="img/crew/crew-02.jpg" alt="">
            <div class="content">
                <h2>
                    Monica Jung 
                    <span>Designer</span>
                </h2>
                <p>
                    Lorem ipsum dolor sit amet consectetur adipisicing elit. 
                    Excepturi harum aperiam eius ad deserunt sed!
                </p>
                <div class="sns">
                    <a href="#none">
                        <i class="fa fa-facebook"></i>
                    </a>
                    <a href="#none">
                        <i class="fa fa-twitter"></i>
                    </a>
                    <a href="#none">
                        <i class="fa fa-instagram"></i>
                    </a>
                </div>
            </div>
        </div>
        <div class="card">
            <img src="img/crew/crew-03.jpg" alt="">
            <div class="content">
                <h2>
                    James Lee
                    <span>Planner</span>
                </h2>
                <p>
                    Lorem ipsum dolor sit amet consectetur adipisicing elit. 
                    Excepturi harum aperiam eius ad deserunt sed!
                </p>
                <div class="sns">
                    <a href="#none">
                        <i class="fa fa-facebook"></i>
                    </a>
                    <a href="#none">
                        <i class="fa fa-twitter"></i>
                    </a>
                    <a href="#none">
                        <i class="fa fa-instagram"></i>
                    </a>
                </div>
            </div>
        </div>
    </div>
cs

 

 

- css

container (중앙정렬 : 포지션 absolute, left50% top50%, 트랜스폼 트랜스레이트(-50%, -50%) 또는 flex 

> card(가로배치 - 인라인블럭) 

hover 시 linear-gradient() 된 자식요소가 나옴  

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
/* card.css */

.container {
/* 중앙정렬 */
    display: flex;
    height: 100vh;
    justify-content: center;
    align-items: center;
}
.card {
    position: relative;
    margin: 10px;
    width: 300px;
    height: 400px;
    overflow: hidden;
    transition: .5s;
}
.card .content {
    position: absolute;
    top: 100%;
    left: 0;
    padding: 20px;
    padding-top: 150px;
    box-sizing: border-box;
    width: inherit;
    height: inherit;
    color: #fff;
    text-align: center;
    transition: .5s;
}
/* .card .content:nth-child(1) X
-> card가 3개이고 card안에 .content는 한개있음
아래 crimson 불투명, 위 투명 (to top)
*/
.card:nth-child(1) .content {
    background: linear-gradient(to top, crimson, transparent);
}
.card:nth-child(2) .content {
    background: linear-gradient(to top, dodgerblue, transparent);
}
.card:nth-child(3) .content {
    background: linear-gradient(to top, yellowgreen, transparent);
}
.card .content h2 {
    font-size: 30px;
}
.card .content h2 span {
    display: block;
    font-size: 14px;
    color: gold;
    margin-top: 10px;
}
.sns a {
    color: #fff;
    display: inline-block;
    border: 1px solid #fff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    line-height: 20px;
    font-size: 12px;
    text-align: center;
}
.card:hover .content {
    top: 0;
}
.card:hover {
    transform: translateY(-20px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.205);
}
cs
 
 
 

 

 

- radio 버튼

동일한 name값을 가져야 다중 선택이 가능함

 

- custom radio button : 배경이미지 이용 ( background: url(img/....jpg) )

백그라운드이미지를 왼쪽 오른쪽으로 이동시킴

1
2
3
4
5
6
7
8
9
10
11
    <div class="grade">
        <h2>Custom Radio</h2>
        <input type="radio" name="grade" id="grade-chk1"> 
        <label for="grade-chk1"><em></em>초등학생</label> 
        <input type="radio" name="grade" id="grade-chk2"> 
        <label for="grade-chk2"><em></em>중학생</label>  
        <input type="radio" name="grade" id="grade-chk3"> 
        <label for="grade-chk3"><em></em>고등학생</label>  
        <input type="radio" name="grade" id="grade-chk4"> 
        <label for="grade-chk4"><em></em>대학생</label>     
    </div>
cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
.grade input[name=grade] {
    display: none;
}
.grade label {
    cursor: pointer;
}
.grade label em {
    /* border: 1px solid red; */
    display: inline-block;
    width: 18px;
    height: 18px;
    vertical-align: middle;
    margin-right: 5px;
    background: url(../img/check/radio-01.png) no-repeat left center;
}
.grade input[type=radio]:checked + label em {
    background-position: right center;
}
.grade input[type=radio]:checked + label {
    color: #f156b6;
}
cs

 


 

- custom checkbox: 폰트어썸 4.7 이용

https://fontawesome.com/v4.7/

before after : input 요소에는 사용할 수 없음 

label:before 

active : 마우스를 눌렀다가 떼지 않은 상태 

 

 

1
2
3
4
5
6
7
8
9
10
    <form action="">
        <input type="checkbox" id="chk1" checked>
        <label for="chk1">HTML</label>
        <input type="checkbox" id="chk2">
        <label for="chk2">CSS</label>
        <input type="checkbox" id="chk3">
        <label for="chk3">jQuery</label>
        <input type="checkbox" id="chk4">
        <label for="chk4">UIKit</label>
    </form>
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
/* 폰트어썸 4.7 */
 
@import url('https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css');
 
form input[type=checkbox] {
    display: none;
}
form label {
    display: block;
    width: 150px;
}
/*
아이콘 유니코드로 content에 넣기  
font-family를 폰트어썸으로 해야함(필수) 
fontsize로 아이콘 사이즈 조절
*/
form label:before {
    content: '\f00c';
    font-family: fontawesome;
    display: inline-block;
    width: 14px;
    height: 14px;
    line-height: 14px;
    border: 1px solid #333;
    border-radius: 3px;
    margin-right: 5px;
    text-align: center;
    vertical-align: middle;
    font-size: 13px;
 
    transition: 0.3s;
    color: transparent;
}
form input[type=checkbox]:checked + label:before {
    background-color: crimson;
    color: #fff;
    border-color: transparent;
}

/* scale(0) 으로 없어졌다가 나타나는 느낌 */
form input[type=checkbox] + label:active:before {
    transform: scale(0);
}
cs

 

- checkbox

<input type="checkbox"> 

체크박스를 이용할 때 텍스트를 눌러도 체크가 가능하게 만들어야한다.

 

input의 id == label의 for 일치시키는 방법 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
    <div class="custom">
        <label>
            <input type="checkbox">
            약관을 충분히 이해하였으며 동의 합니다.
        </label>
    </div>

    <!-- 추천 방법  -->
    <div class="custom">
        <input type="checkbox" id="agree-chk">
        <label for="agree-chk">
            약관을 충분히 이해하였으며 동의 합니다.
        </label>
    </div>
cs

 

 


- custom checkbox 만들기

체크박스 이미지를 하나 준비한다. label안에 이미지를 넣을 태그 하나 만들어야한다.

이 예제에서는 em태그로 했지만 다른 태그도 가능

처음에 빈 체크박스 이미지를 보여주고 checked 되면 체크된 이미지를 보여준다. (백그라운드 포지션 right center)

- html

1
2
3
4
5
    <div class="custom">
        <input type="checkbox" id="chk">
        <label for="chk"><em></em>약관을 충분히 이해하였으며 동의 합니다.
        </label>
    </div>
cs

 

 

- css 

em은 인라인요소이다. 

백그라운드-포지션: left (수평), center (수직) // 디폴트값

:checked 눌렀을 때 

+ 인접선택자 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
.custom input[type=checkbox] {
    /* html에서 기능을 하지않는 것이 아니라 보이지 않는것임 */
    display: none;
}
.custom label em {
    display: inline-block;
    /* border: 1px solid red; */
    width: 18px;
    height: 18px;
 
    /* 인라인 끼리 중앙을 맞출때 */
    vertical-align: middle;
 
    margin-right: 5px;
    background: url(../img/check/checkbox-01.png) no-repeat;
   /* background-position: left center; */
}
/* type=checkbox체크 박스를 눌렀을 때 그 바로밑에 있는 label em 요소
+ 인접선택자 : 바로 밑에 요소 */
.custom input[type=checkbox]:checked + label em {
    background-position: right center;
}
cs

 

 

 

 

 

 

 

a:before a:after 만들고 

호버 시에 비포 에프터에 각각 rotate(45deg) rotate(-45deg)  

글씨는 letter-spacing 크게 

1
2
3
<div class="rotate-navi">
    <a href="#none">CodingWorks Online Class</a>
</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
.rotate-navi {
    margin: 50% 0; 없어도 됨 
}    
.rotate-navi a {
    position: relative;
    display: block;
    padding: 15px;
    width: 450px;
    box-sizing: border-box;
    /* 보더박스를 안하면 패딩을 넣었을 때 a의 크기가 커진다. */
    text-align: center;
    color: #fff;
    text-transform: uppercase;
    /* border: 1px solid red; */
    transition: 0.3s;
}
.rotate-navi a:before,
.rotate-navi a:after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid #7e7e7e;
    transition: 0.3s;
}
.rotate-navi a:hover {
    letter-spacing: 5px;
}
.rotate-navi a:hover:before {
    transform: rotate(45deg);
    background-color: transparent;
}
.rotate-navi a:hover:after {
    transform: rotate(-45deg);
    background-color: transparent;
}
cs

 

 

before after 가상클래스를 이용한 hover effect 

before after 두개 만들고 호버 시에 top위치 바꿔서 스크롤되는 느낌 

 

 

- 사용자 정의 속성 :

속성 == property == attribute 

a:before {}

a:after {}

before after 가상클래스 안에서 content: 'CodingWorks Online Class'; 또는 content: attr(내가 만든 사용자정의 속성)을 이용해 사용자 정의 속성을 불러온다.

일반적으로 data-text, data-image ... "data-xxx" 형식으로 정의한다.

    <div class="gnb">
    <!-- 
    	1. a 태그안에 직접 텍스트를 입력
    	2. data-text라는 사용자 정의 속성을 만들고 content attr로 불러오기  
    -->
    	<a href="#none">CodingWorks Online Class</a>
        <a href="#none" data-text="CodingWorks Online Class"></a>
    </div>

a 태그안에 직접 입력한 텍스트만 나온다. 

아직 data-text 속성을 불러오지 않아서 

 

 

body {
    line-height: 1.5em;
    font-weight: 300;
    margin: 30px;
}
a {
    text-decoration: none;
}
.gnb a {
    position: relative;
    display: block;
    border: 5px solid coral;
    width: 250px;
    height: 40px;
    line-height: 40px;
    
}
.gnb a:before, .gnb a:after {
    content: attr(data-text);
    position: absolute;
    width: inherit;
    height: inherit;
    color: #fff;
    text-transform: uppercase;
    text-align: center;
    transition: 0.3s;
}
.gnb a:before {
    background-color: crimson;
    top: 0;
}
.gnb a:after {
    background-color: deepskyblue;
    top: 100%;
}
.gnb a:hover:before {
    top: -100%;
}
.gnb a:hover:after {
    top: 0;
}

a에 border그리고 테스트 

a:before, a:after 포지션 absolute -> 부모요소인 a가 relative 

a:before top0, a에 위치 호버되면 top -100%로 a(부모요소) 위로 올라감

a:after top:100% a밑에 있다가 호버되면 top0로 a에 위치함 

 

마지막에 a 에 오버플로우 히든 넣고 보더 지워주기

 

 

+ Recent posts