Search box
フォーカスで幅が広がる検索ボックス
by Kissy
HTML
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.1/css/all.css">
<form method="get" class="fa fa-search search-form" action="https://bgt-48.blogspot.com/search">
<input type="search" placeholder="キーワードを入力して、Enter" value="" name="q" class="search-text" />
<input type="submit" value="Search" />
</form>
CSS
.search-form {
display: block;
position: relative;
}
.search-form:before, .search-text {
position: absolute;
top: 0;
left: 0;
width: 3em;
height: 3em;
margin: 0;
border-radius: 1.5em;
font-size: 1em;
}
.search-form:before {
z-index: 100;
line-height: 3em;
background: #65b1e4;
color: #FFF;
text-align: center;
}
.search-text {
opacity: 0;
z-index: 200;
cursor: pointer;
transition: .5s;
outline: 0;
border: solid 1px #ccc;
border-radius: 1.5em;
padding-left: 1em;
}
.search-text:focus {
opacity: 1;
width: 100%;
cursor: text;
}
.search-form input[type="submit"] {
display: none;
}