<div class="srch"> <form action="{getUrl()}" method="get" no-error-return-url="true"> <input type="hidden" name="vid" value="{$vid}" /> <input type="hidden" name="mid" value="{$mid}" /> <input type="hidden" name="act" value="IS" /> <input class="input" type="search" name="is_keyword" value="{$is_keyword}" title="{$lang->cmd_search}" /> </form> </div>
우선 이게 검색창이구요
#hd .srch{position:relative;float:right;width:200px;margin:10px 6px 0;padding:0;border-style:none;*zoom:1;*height:22px} #hd .srch .input{width:100%;height:27px;padding:5px;border:1px solid #738bcf;border-radius:5px;background:url("../img/google_custom_search_watermark.gif") 5px no-repeat;} #hd .srch .input:focus{outline: 0;background:#fff} #hd .srch .input:valid{background:#fff}
CSS를 이런 식으로 넣었는데..
다른건 다 됐는데, 검색창에 커서를 두거나 입력하지 않은 상태에서만 백그라운드 이미지를 보여 주고
포커스를 두거나 뭔가 타이핑했을 때에는 백그라운드 이미지를 숨기고 싶은데 이 부분이 잘 안되네요
포커스를 뒀을 때 숨기는 방법은 :focus 에서 "background:#fff" 를 해 주니까 해결되는데,
문제는 뭔가를 입력했을 때 포커스를 다른 곳으로 옮기면 다시 백그라운드 이미지가 나타나네요.
해당 부분을 스샷으로 찍으면 이렇게 됩니다.
타이핑할 때 까지는 백그라운드 이미지가 제대로 숨겨지는데, 타이핑하고 나서 다른 곳을 클릭하면 저렇게 되어 버리네요
그래서 알아본 끝에 다른 사이트에서는 :vaild 값을 넣어서 해결했길래, 똑같이 따라해 봤는데요
문제는, 다른 사이트는 뭔가를 입력했을 때만 :valid가 활성화되던데, 저는 그냥 기본적으로 활성화되어 있더군요.
즉, 기본적으로 :vaild 인 상태가 되어서, 결국 뭔가를 타이핑하지 않아도 백그라운드 이미지가 출력이 안 됩니다.
지금 여기서 막힌 상태입니다. 아무리 검색해봐도 대체 왜 그런지 알 수가 없네요
혹시 이거 해결법 아시는 분 계시면 도와주시면 감사하겠습니다.
테스트중인 사이트 주소는 https://metalgall.net/test 입니다.