Created
July 4, 2013 23:42
-
-
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.
This file contains 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
form.search | |
input.searchTerm placeholder="Enter your search term ..." | |
input.searchButton type="submit" | |
span.searchIcon |
This file contains 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
$('.searchButton').on('click',function(){ | |
alert('You clicked search button'); | |
}); |
This file contains 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
.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