Last active
August 29, 2015 14:07
-
-
Save harisrozak/c4624428bbd59ac6912c to your computer and use it in GitHub Desktop.
HTML + CSS + JS :: Expandable Search Form
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="style.css" rel="stylesheet"> | |
<h1>Expandable Search Form</h1> | |
<h3>Demo 1</h3> | |
<form> | |
<input type="search" placeholder="Search"> | |
</form> | |
<h3>Demo 2</h3> | |
<form id="demo-2"> | |
<input type="search" placeholder="Search"> | |
</form> | |
<!-- form http://codepen.io/912lab/pen/LsplC --> | |
<!-- by prinzadi --> | |
<!-- edited by harisrozak --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
background: #fff; | |
color: #666; | |
font: 90%/180% Arial, Helvetica, sans-serif; | |
width: 800px; | |
max-width: 96%; | |
margin: 0 auto; | |
} | |
a { | |
color: #69C; | |
text-decoration: none; | |
} | |
a:hover { | |
color: #F60; | |
} | |
h1 { | |
font: 1.7em; | |
line-height: 110%; | |
color: #000; | |
} | |
p { | |
margin: 0 0 20px; | |
} | |
input { | |
outline: none; | |
} | |
input[type=search] { | |
-webkit-appearance: textfield; | |
-webkit-box-sizing: content-box; | |
font-family: inherit; | |
font-size: 100%; | |
} | |
input::-webkit-search-decoration, | |
input::-webkit-search-cancel-button { | |
display: none; | |
} | |
input[type=search] { | |
background: #ededed url(http://static.tumblr.com/ftv85bp/MIXmud4tx/search-icon.png) no-repeat 9px center; | |
border: solid 1px #ccc; | |
padding: 9px 10px 9px 32px; | |
width: 90px; | |
-webkit-border-radius: 10em; | |
-moz-border-radius: 10em; | |
border-radius: 10em; | |
-webkit-transition: all .5s; | |
-moz-transition: all .5s; | |
transition: all .5s; | |
-webkit-box-sizing: border-box; | |
-moz-box-sizing: border-box; | |
box-sizing: border-box; | |
} | |
input[type=search]:focus { | |
width: 200px; | |
background-color: #fff; | |
border-color: #66CC75; | |
-webkit-box-shadow: 0 0 5px rgba(109,207,246,.5); | |
-moz-box-shadow: 0 0 5px rgba(109,207,246,.5); | |
box-shadow: 0 0 5px rgba(109,207,246,.5); | |
} | |
input:-moz-placeholder { | |
color: #999; | |
} | |
input::-webkit-input-placeholder { | |
color: #999; | |
} | |
/* Demo 2 */ | |
#demo-2 input[type=search] { | |
width: 38px; | |
padding-left: 10px; | |
color: transparent; | |
cursor: pointer; | |
-webkit-box-sizing: border-box; | |
-moz-box-sizing: border-box; | |
box-sizing: border-box; | |
} | |
#demo-2 input[type=search]:hover { | |
background-color: #fff; | |
} | |
#demo-2 input[type=search]:focus { | |
width: 200px; | |
padding-left: 32px; | |
color: #000; | |
background-color: #fff; | |
cursor: auto; | |
} | |
#demo-2 input:-moz-placeholder { | |
color: transparent; | |
} | |
#demo-2 input::-webkit-input-placeholder { | |
color: transparent; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment