Skip to content

Instantly share code, notes, and snippets.

@dodozhang21
Created July 4, 2013 23:42
Show Gist options
  • Save dodozhang21/5930842 to your computer and use it in GitHub Desktop.
Save dodozhang21/5930842 to your computer and use it in GitHub Desktop.
A CodePen by dodozhang21. Responsive search bar - A great technique of styling a search bar.
form.search
input.searchTerm placeholder="Enter your search term ..."
input.searchButton type="submit"
span.searchIcon
$('.searchButton').on('click',function(){
alert('You clicked search button');
});
.search {
position: relative;
width: 100%;
}
.searchTerm {
position: absolute;
top: 0;
left: 0;
width: 100%;
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box;
height: 40px;
border: 5px solid #8FC357;
border-radius: 5px;
outline: none;
padding: 5px 45px 5px 5px;
}
.searchButton,
.searchIcon {
display: block;
position: absolute;
top: 0;
right: 0;
width: 40px;
height: 40px;
line-height: 40px;
font-family: 'FontAwesome';
background: #8FC357;
text-align: center;
color: #fff;
border-radius: 5px;
-webkit-font-smoothing: subpixel-antialiased;
font-smooth: always;
cursor: pointer;
}
.searchButton {
opacity: 0;
z-index: 1;
}
.searchIcon:before {
content: '\f002';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment