티스토리 뷰
HTML
<h1>Nice input box</h1>
<form>
<input type="text" name="name" class="question" id="nme" required autocomplete="off" />
<label for="nme"><span>What's your name?</span></label>
<textarea name="message" rows="2" class="question" id="msg" required autocomplete="off"></textarea>
<label for="msg"><span>What's your message?</span></label>
<input type="submit" value="Submit!" />
</form>
CSS
/*
Basic input element using psuedo classes
*/
html {
font-family: 'Lora', sans-serif;
width: 100%;
}
body {
margin: 5% auto 0 auto;
width: 90%;
max-width: 1125px;
}
h1 {
font-size: 28px;
margin-bottom: 2.5%;
}
input,
span,
label,
textarea {
font-family: 'Ubuntu', sans-serif;
display: block;
margin: 10px;
padding: 5px;
border: none;
font-size: 22px;
}
textarea:focus,
input:focus {
outline: 0;
}
/* Question */
input.question,
textarea.question {
font-size: 48px;
font-weight: 300;
border-radius: 2px;
margin: 0;
border: none;
width: 80%;
background: rgba(0, 0, 0, 0);
transition: padding-top 0.2s ease, margin-top 0.2s ease;
overflow-x: hidden; /* Hack to make "rows" attribute apply in Firefox. */
}
/* Underline and Placeholder */
input.question + label,
textarea.question + label {
display: block;
position: relative;
white-space: nowrap;
padding: 0;
margin: 0;
width: 10%;
border-top: 1px solid red;
-webkit-transition: width 0.4s ease;
transition: width 0.4s ease;
height: 0px;
}
input.question:focus + label,
textarea.question:focus + label {
width: 80%;
}
input.question:focus,
input.question:valid {
padding-top: 35px;
}
textarea.question:valid,
textarea.question:focus {
margin-top: 35px;
}
input.question:focus + label > span,
input.question:valid + label > span {
top: -100px;
font-size: 22px;
color: #333;
}
textarea.question:focus + label > span,
textarea.question:valid + label > span {
top: -150px;
font-size: 22px;
color: #333;
}
input.question:valid + label,
textarea.question:valid + label {
border-color: green;
}
input.question:invalid,
textarea.question:invalid {
box-shadow: none;
}
input.question + label > span,
textarea.question + label > span {
font-weight: 300;
margin: 0;
position: absolute;
color: #8F8F8F;
font-size: 48px;
top: -66px;
left: 0px;
z-index: -1;
-webkit-transition: top 0.2s ease, font-size 0.2s ease, color 0.2s ease;
transition: top 0.2s ease, font-size 0.2s ease, color 0.2s ease;
}
input[type="submit"] {
-webkit-transition: opacity 0.2s ease, background 0.2s ease;
transition: opacity 0.2s ease, background 0.2s ease;
display: block;
opacity: 0;
margin: 10px 0 0 0;
padding: 10px;
cursor: pointer;
}
input[type="submit"]:hover {
background: #EEE;
}
input[type="submit"]:active {
background: #999;
}
input.question:valid ~ input[type="submit"], textarea.question:valid ~ input[type="submit"] {
-webkit-animation: appear 1s forwards;
animation: appear 1s forwards;
}
input.question:invalid ~ input[type="submit"], textarea.question:invalid ~ input[type="submit"] {
display: none;
}
@-webkit-keyframes appear {
100% {
opacity: 1;
}
}
@keyframes appear {
100% {
opacity: 1;
}
}
실행화면보기
'css3' 카테고리의 다른 글
패럴럭스(Parallax Scroll) 원리 간단하게 배우기 (0) | 2020.03.09 |
---|---|
placeholder css 스타일 적용하기 (0) | 2018.03.30 |
-webkit-overflow-scrolling (0) | 2017.08.17 |
CSS flex: Webkit, Android 2.1~4.3 이슈 (0) | 2017.08.10 |
flexbox 배우기 (0) | 2017.03.02 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 부트스트랩class명
- WAI-ARIA탭메뉴
- 접근성 tabmenu
- 깃허브
- bxslider
- WAI-ARIA tab menu
- VSCode
- SFPro웹폰트
- SFPro web font
- 접근성탭메뉴
- 웹 접근성
- San Francisco웹폰트
- 키보드 웹접근성
- Flexbox
- San Francisco web font
- 부트스트랩 네이밍
- placeholder css
- PlaceHolder
- Git
- one scroll
- node.js
- 애플웹폰트
- 자바스크립트 탭메뉴
- CSS3
- 웹폰트
- 키보드접근성자바스크립트
- 반응형웹
- 본고딕
- 패럴럭스 스크롤
- jquery
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함