- 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 에 오버플로우 히든 넣고 보더 지워주기

 

 

 

- html

    <div class="gnb">
        <a href="#none">before hover effect example</a>
    </div>

 

 

포지션으로 위치를 잡을거라서 before, after이던 상관이 없음 
before after :

content=''; 필수로 있어야함, 인라인요소 (크기값을 가질 수 없음)

position: absolute - 인라인블럭 (크기값 가짐)

 

- css

a {
    text-decoration: none;
    color: #000;
}
div {
    margin: 10px 0;
}
/* 공통 */
.gnb a {
    position: relative;
    padding-bottom: 5px;
}
.gnb a:before {
    content: '';
    position: absolute;
    bottom: 0;
    background-color: crimson;
    transition: 0.3s;
}

/* underline 왼쪽 -> 오른쪽 */
.gnb a:before {
    width: 0;
    height: 1px;
}
.gnb a:hover:before {
/* a에 호버될때 자기자신의 before */
    width: 100%;
}

/* underline 오 -> 왼 */
.gnb2 a:before {  
    width: 0;
    height: 1px;
    right: 0;
}
.gnb2 a:hover:before {
    width: 100%;
}

/* 도트 왼 -> 오 */
.gnb3 a:before { 
    width: 4px;
    height: 4px;
    left: 0;
}
.gnb3 a:hover:before {
    /* left: 100%; 또는 calc로 계산해주기 */
    /* left:100%는 부모요소의 끝 점 */
    left: calc(100% - 4px);
}

/* 중앙 -> 바깥쪽 */
.gnb4 a:before {  
    width: 0px;
    height: 1px;
    left: 50%;
    transform: translateX(-50%);
}
.gnb4 a:hover:before {
    width: 100%;
}
/* 바깥쪽 -> 중앙 */
.gnb5 a:before { 
    width: 100%;
    height: 1px;
    left: 50%;
    transform: translateX(-50%);
}
.gnb5 a:hover:before {
    width: 0;
}

/* background 와 background-image의 차이
background-image 속성은 이미지만 추가 할 수 있다. 
background-image: url('xx.jpg')

 

background
background-color repeat no-repeat 및 기타 속성을 추가 

- 이미지 경로 : 절대경로, 상대경로
절대경로 : <a href="http://xxx.co.kr">클릭</a>
상대경로 : 상대적으로 변경될 수 있는 경로 url(../img/xx.jpg)
*/

 

- html 

<!-- 풀 스크린 슬라이더 -->
<!-- 
	tabs - overflow:hidden 
	items - w300% 
    items>div - w33.33333%
-->
    <div class="tab-inner">     
        <input type="radio" name="t" id="tab1" checked>
        <input type="radio" name="t" id="tab2">
        <input type="radio" name="t" id="tab3">
        <div class="tabs">
            <div class="items">
                <div>
                    <h1>Slide Content 01</h1>
                </div>
                <div>
                    <h1>Slide Content 02</h1>
                </div>
                <div>
                    <h1>Slide Content 03</h1>
                </div>
            </div>
        </div>
        <div class="btn">
            <label for="tab1">Graphic</label>
            <label for="tab2">Web Publishing</label>
            <label for="tab3">Logo & CI</label>
        </div>
    </div>

 

- css

/* 풀스크린 슬라이더 css 완성본 */
body {
    padding: 0;
    margin: 0;
}
.tab-inner {
    /* container 기능 */
}

 /* 라디오버튼3개 안보이게 */
input[name=t] {
    display: none;
}

/* div.tabs 는 블럭요소라서 w100%가 디폴트값임 */
.tabs {
    overflow: hidden;

    /* 자식요소가 absolute이면 자식요소가 붕뜸
    부모요소가 자식만큼 높이를 가지고 있다가 높이값 잃음
    높이값을 안주면 overflow:hidden으로 내용이 다 사라짐  */
    position: relative;
    height: 100vh;
}
/* items > div*3 */
.items {
    /* border: 1px solid blue; */
    width: 300%;
    height: 100vh;
    transition: 0.5s;

    position: absolute;
    top: 0;
    left: 0;
}
/* .items div 가 부모요소
div에 before after로 그라디언트를 넣을 것임 
부모요소relative가 없으면 자식:before의 시작 끝을 알 수 없음 */
.items div {
    position: relative;
    height: 100vh;
    float: left;
    /* width: 100%;로 하면 안된다, 33.33333% 로 퍼센트로 나눠야함 */
    width: 33.33333%;
    box-sizing: border-box;
    /* border: 1px solid red; */
}
.items div:nth-child(1) {
    background: url(../img/photo-01.jpg) no-repeat center center;
    background-size: cover;
    background-attachment: fixed;
    /* 이미지가 스크롤되지 않고 고정된 느낌, 이미지만 그대로 있고 content만 바뀌게 보인다. */
}
.items div:nth-child(2) {
    background: url(../img/photo-02.jpg) no-repeat center center fixed;
    background-size: cover;
}
.items div:nth-child(3) {
    background: url(../img/photo-03.jpg) no-repeat center center fixed;
    background-size: cover;
}

/* 비포로 그라이언트 넣기 */
.items div:nth-child(1):before,
.items div:nth-child(2):before,
.items div:nth-child(3):before {
    content: '';
    position: absolute;
    /* 135deg : 왼쪽 상단 -> 오른쪽 하단 */
    width: 100%;
    height: 100%;
}
.items div:nth-child(1):before {
    background: linear-gradient(135deg, gold, transparent);
}
.items div:nth-child(2):before {
    background: linear-gradient(135deg, crimson, transparent);
} 
.items div:nth-child(3):before {
    background: linear-gradient(135deg, royalblue, transparent);
}  

.items div h1 {
    /* 배경위로 텍스트가 올라옴 
    z-index를 주지 않으면 absolute보다 relative가 우선이다 
    같은 relative면 마지막에 적은게 먼저 올라옴*/
    position: relative;
    text-align: center;
    font-size: 130px;
    font-weight: normal;
    color: #fff;
    transform: translateY(-200px);
    opacity: 0;
    transition: 0.5s;

    /* .items가 left로 0 -100% -200%로 밀리면서 배경이 바뀐다.(transition이 0.5s) 
    트랜지션딜레이:0.5s 배경이 바뀌고 나서 그다음에 h1이 상단에서 내려온다.  */
    transition-delay: 0.5s;
}

.btn {
    /* 하단 네비게이션 bottom:0 */
    position: absolute;
    bottom: 0px;
    /* left: 50%;
    transform: translateX(-50%); 
    로 해도 되지만 ,

    absolute -> 인라인블럭이 되기때문에
    w100% ta:c */
    width: 100%;
    height: 50px;
    line-height: 50px;
    text-align: center;
    background: rgba(0, 0, 0, 0.3);
}

.btn label {
    display: inline-block;
    /* 
    네비게이션 
    width: 50px;
    height: 5px;
    background-color: #fff; */
    color: #fff;
    margin: 0 15px;
    cursor: pointer;
}
input[id=tab1]:checked ~ .tabs .items {
    left: 0;
}
input[id=tab2]:checked ~ .tabs .items {
    left: -100%;
}
input[id=tab3]:checked ~ .tabs .items {
    left: -200%;
}
input[id=tab1]:checked ~ .btn label[for=tab1],
input[id=tab2]:checked ~ .btn label[for=tab2],
input[id=tab3]:checked ~ .btn label[for=tab3] {
    color: crimson;
}

input[id=tab1]:checked ~ .tabs .items div:nth-child(1) h1,
input[id=tab2]:checked ~ .tabs .items div:nth-child(2) h1,
input[id=tab3]:checked ~ .tabs .items div:nth-child(3) h1 {
    transform: translateY(200px);
    opacity: 1;
}

+ Recent posts