JQuery 다음 검색창 UI 구현

(JQuery 다음 검색창 구현에서 넘어옴)

1 개요[ | ]

jQuery 다음 검색창 구현
  • Daum 검색창은 전체가 이미지로 구성되어 있음
아래 소스코드에는 각각 base64형식으로 되어 있으나, 실제 사이트는 스프라이트 방식
  • 순수 CSS만으로는 구현 불가
input text에 포커스가 갈 때 부모의 테두리선 색상을 바꿔야 하기 때문
CSS는 역방향접근(여기서는 부모 속성 접근)이 불가능함[1]

2 소스 코드[ | ]

<style>
body { background: white; }
.box_search {
	margin: 0; padding: 0;
	width: 444px;
	overflow: hidden;
	background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXoAAAAnCAYAAAABx4MNAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAADYSURBVHja7NQ7CsJAAEXRN0Fi/GCtuP/VpLOzGLCzC2i6aeI6HM5Zwi1u+Xy/W329U5+PANCfMs/zdr3dczpOagB0aNday+VyzrTfZxgGRQB6G32SHKYppRQ1ADo0JDF5gN5HD4DRA2D0ABg9AEYPgNEDYPQAGD2A0QNg9AAYPQBGD4DRA2D0ABg9gNEDYPQAGD0ARg+A0QNg9AAYPYDRSwBg9AAYPQBGD4DRA2D0ABg9AEYPYPQAGD0A/zH6cRyzrqsSAJ0qy7Jstda01tQA6NAPAAD//wMARAsco4Q7s7oAAAAASUVORK5CYII=');
}
.box_search_on {
	background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXoAAAAnCAYAAAABx4MNAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAADrSURBVHja7NSxDQFhGIDh7z+n4EJnAYUVJBJLGMFGChtYwQA67XWiukqjkYtISOQ3hz/PM8JbvKntPvlwesbllgKA8qTt/pE3y2Gs5m81AApU3/sc68U3xqNJ1HWtCEBpo4+IaMZNDAaVGgAFqiLC5AFKHz0ARg+A0QNg9AAYPQBGD4DRA2D0AEYPgNEDYPQAGD0ARg+A0QNg9ABGD4DRA2D0ABg9AEYPgNEDYPQARi8BgNEDYPQAGD0ARg+A0QNg9AAYPYDRA2D0APzH6GfTFOfrWwmAQqW2++Td8RX3PqsBUKAfAAAA//8DABkaHPQpAjoqAAAAAElFTkSuQmCC');
}
.tf_keyword {
	float: left;
	margin: 10px 10px 0;
	padding: 0; border: 0;
	width: 358px; height: 20px;
	color: #333;
	font-weight: bold;
	font-size: 16px;
	line-height: 18px;
	background-color: transparent;
	outline: none;
}
.btn_search {
	float: left;
	overflow: hidden;
	margin: 0; padding: 0; border: 0;
	width: 66px; height: 39px;
	cursor: pointer;
	background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAAAnCAIAAAA0DwlWAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAOLSURBVHja7FhNaFxVFP7u39z37sxkOozSWlJoSm2oIlSIP7E6UEQpiBFaslAMBUEX3VgEd1ll6c5NoQsR7EoQwUCJCqZgFYskKKkoNjSmUm3aSQsz7//vXhdPqwF3c1M7Moe7eH+8+75zznfO9w6ZmluH3IGBtftqePMFxQG0mo3BhRGn+bvnAg7AmMFFgYrgnduG4n9hQxj3knEAeqDJAWgz5MYQhmUzWnMAWtt/dRAFcZrpIgdAGZe8olxJKdtGilsHQHX88mF1aKz24C4B4Nqt/JvL6fxS14+cWlUNAAzPDyb2FW+92FIVcufiaItPT/KpCfe9L/zPLwX1WtV2pdI2ueEH4aN789njjTsYVjey1Y2sPJaCnDxaf/4R4wfhvRsNrQuG6O2XWuXpueXw/fNhmDMAnOiZtjs9qQC8/lx1ec3zM10R1DIMK+0vjJJXDqsyDouXojOLhSubTUUA5Lk5+1UIhNOTSjB67AlxZjHk3GZqWXNJkqeHxgSAJDOnPwucisP5n6nFOXG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ery.com/jquery.min.js"></script>
<script>
$(function() {
	$('.tf_keyword')
		.focus(function() {
			$('.box_search').addClass('box_search_on');
		})
		.blur(function() {
			$('.box_search').removeClass('box_search_on');
		});
});
</script>

<form>
	<div class="box_search">
		<input type="text" class="tf_keyword" title="검색어 입력" />
		<button type="submit" class="btn_search"></button>
	</div>
</form>

3 같이 보기[ | ]

4 주석[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}