간단한 OverLabel 정보
간단한 OverLabel본문
* CSS :
.class{ margin: 5px 9px; position: absolute; }
#input:focus { position: relative; }
* Script
function overlabel(id) {
if(id.value != "") {
id.style.position = "relative";
}
else {
id.style.position = "";
}
}
* Apply
<label for="id" class="class">라벨</label>
<input type="text" id="input" onblur="overlabel(this);" />
* 실 적용 예제 *
<style type="text/css">
<!--
#outlogin .formlabel { margin: 5px 9px; position: absolute; }
#outlogin input:focus { position: relative; } /* 체크박스 걱정은 안하셔도 됩니다. */
-->
</style>
<div id="outlogin">
<label for="mb_id" class="formlabel">아이디</label>
<input type="text" id="mb_id" onblur="overlabel(this);" />
<label for="mb_password" class="formlabel">열쇠글</label>
<input type="text" id="mb_password" onblur="overlabel(this);" />
</div>
[EOF]
*자바스크립트 function을 태그에 직접 넣지 않고 싶을 때
document.getElementById("mb_id").onblur = function() { overlabel(this); }
document.getElementById("mb_password").onblur = function() { overlabel(this); }
제가 쓰는 방법입니다. 인풋 박스가 라벨을 덮어버리는 구조입니다.
라벨의 바깥 여백은 input의 높이에 따라 조절하세요.
아래는 라벨을 한쪽으로 치우는 방법입니다. Jquery를 이용합니다.
http://sir.co.kr/bbs/tb.php/g4_tiptech/19498/a1d3a62a38d7ad4106ecb7915c383462
.class{ margin: 5px 9px; position: absolute; }
#input:focus { position: relative; }
* Script
function overlabel(id) {
if(id.value != "") {
id.style.position = "relative";
}
else {
id.style.position = "";
}
}
* Apply
<label for="id" class="class">라벨</label>
<input type="text" id="input" onblur="overlabel(this);" />
* 실 적용 예제 *
<style type="text/css">
<!--
#outlogin .formlabel { margin: 5px 9px; position: absolute; }
#outlogin input:focus { position: relative; } /* 체크박스 걱정은 안하셔도 됩니다. */
-->
</style>
<div id="outlogin">
<label for="mb_id" class="formlabel">아이디</label>
<input type="text" id="mb_id" onblur="overlabel(this);" />
<label for="mb_password" class="formlabel">열쇠글</label>
<input type="text" id="mb_password" onblur="overlabel(this);" />
</div>
[EOF]
*자바스크립트 function을 태그에 직접 넣지 않고 싶을 때
document.getElementById("mb_id").onblur = function() { overlabel(this); }
document.getElementById("mb_password").onblur = function() { overlabel(this); }
제가 쓰는 방법입니다. 인풋 박스가 라벨을 덮어버리는 구조입니다.
라벨의 바깥 여백은 input의 높이에 따라 조절하세요.
아래는 라벨을 한쪽으로 치우는 방법입니다. Jquery를 이용합니다.
http://sir.co.kr/bbs/tb.php/g4_tiptech/19498/a1d3a62a38d7ad4106ecb7915c383462
추천
1
1
댓글 3개
<label for="name">라벨</label><input id="name" type="text" />
이렇게만 해도 라벨글자를 클릭하면 폼이 활성화 되잖아요.
어떤 부분이 다른지 모르겠어요 ㅠ
이렇게만 해도 라벨글자를 클릭하면 폼이 활성화 되잖아요.
어떤 부분이 다른지 모르겠어요 ㅠ
sir 왼쪽 로그인 폼 처럼 작동 되는걸 말합니다.
라벨에 position: absolute;를 주면 라벨이 인풋 박스 위를 떠다니겠죠.
활성화 되면 input에 position: relative;를 주게되면서 라벨 위에 위치하게 됩니다.
즉 라벨은 그 위치에 그대로 있지만, 안보이게 된다는 거죠.
활성화 되면 input에 position: relative;를 주게되면서 라벨 위에 위치하게 됩니다.
즉 라벨은 그 위치에 그대로 있지만, 안보이게 된다는 거죠.