<div class="textbox">
<label for="ex_input">아이디</label>
<input type="text" id="ex_input">
</div>
<div class="textbox">
<label for="ex_input2">패스워드</label>
<input type="password" id="ex_input2">
</div>
<a href="http://webdir.tistory.com/429" target="_blank" class="where">posted in webdir</a>
.where {
display: block;
margin: 25px 15px;
font-size: 11px;
color: #000;
text-decoration: none;
font-family: verdana;
font-style: italic;
}
.textbox {position: relative; width: 200px; margin: 15px}
.textbox label {
position: absolute;
top: 1px; /* input 요소의 border-top 설정값 만큼 */
left: 1px; /* input 요소의 border-left 설정값 만큼 */
padding: .8em .5em; /* input 요소의 padding 값 만큼 */
color: #999;
cursor: text;
}
.textbox input[type="text"],
.textbox input[type="password"] {
width: 100%; /* 원하는 너비 설정 */
height: auto; /* 높이값 초기화 */
line-height : normal; /* line-height 초기화 */
padding: .8em .5em; /* 원하는 여백 설정, 상하단 여백으로 높이를 조절 */
border: 1px solid #999;
border-radius: 0; /* iSO 둥근모서리 제거 */
outline-style: none; /* 포커스시 발생하는 효과 제거를 원한다면 */
-webkit-appearance: none; /* 브라우저별 기본 스타일링 제거 */
-moz-appearance: none;
appearance: none;
}
$(document).ready(function() {
var placeholderTarget = $('.textbox input[type="text"], .textbox input[type="password"]');
//포커스시
placeholderTarget.on('focus', function(){
$(this).siblings('label').fadeOut('fast');
});
//포커스아웃시
placeholderTarget.on('focusout', function(){
if($(this).val() == ''){
$(this).siblings('label').fadeIn('fast');
}
});
});
This Pen doesn't use any external CSS resources.