Skip to content

Instantly share code, notes, and snippets.

@dwkiner
Created January 16, 2019 15:58
Show Gist options
  • Save dwkiner/1800ca8e8b9cffb5f798655dfba6fe49 to your computer and use it in GitHub Desktop.
Save dwkiner/1800ca8e8b9cffb5f798655dfba6fe49 to your computer and use it in GitHub Desktop.
Responsive search bar
form.search
input.searchTerm placeholder="Enter your search term ..."
input.searchButton type="submit"
$('.searchButton').on('click',function(){
alert('You clicked search button');
});
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
@import "compass/css3";
@import url(https://netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css);
$iconColor: #fff;
$color: #8FC357;
.search {
width: 100%;
position: relative;
&:before {
position: absolute;
top: 0;
right: 0;
width: 40px;
height: 40px;
line-height: 40px;
font-family: 'FontAwesome';
content: '\f002';
background: $color;
text-align: center;
color: $iconColor;
border-radius: 5px;
-webkit-font-smoothing: subpixel-antialiased;
font-smooth: always;
}
}
.searchTerm {
@include box-sizing(border-box);
width: 100%;
border: 5px solid $color;
padding: 5px;
height: 40px;
border-radius: 5px;
outline: none;
}
.searchButton {
position: absolute;
top: 0;
right: 0;
width: 40px;
height: 40px;
opacity: 0;
cursor: pointer;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment