input input - 4 years ago 117
CSS Question

Font Awesome with easyAutocomplete plugin

I have a form in which I want to show the input text field and submit on the same line. The input text field has two FontAwesome icons which I want to show inside the text field. I can style the form as I want when I don't use the easy Autocomplete plugin. But when I activate the easyAutocomplete plugin, the styling goes haywire.

Here's the code:

HTML:

<form role="search" method="get" id="searchform" class="searchform" action="">
<span class="fa fa-map-marker my-fa"></span>
<input type="text" value="" name="s" id="search-input" class="s" placeholder="Enter your Postcode" autocomplete="off">
<img id="slider-loading" class="loading" src="https://www.imageupload.co.uk/images/2017/02/05/gps2.gif" />
<input type="hidden" value="profile" name="post_type" id="post_type" />
<input type="hidden" value="country" name="taxonomy" />
<input type="submit" id="searchsubmit" value="GO" class="submit btn" />
</form>


jQuery

var options = {

data: ["Cyclops", "Storm", "Mystique", "Wolverine", "Professor X", "Magneto"],

theme: "dark"
};

$("#search-input").easyAutocomplete(options);


CSS:

.searchform {
position: relative;
text-align: center;
}

.searchform input[type="text"] {
width: 400px;
font-size: 15px;
margin: 0px -3px 0px 0px;
text-indent: 18px;
padding: 15px;
text-transform: uppercase;
letter-spacing: 1px;
font-weight: 300;
font-family: 'Raleway', sans-serif;
border: solid 1px #bbb;
overflow: hidden;
border-radius: 4px;
}

.searchform input[type=text],
.searchform input[type=text]:focus {
outline: none;
}

.searchform input[type=text]:focus {
border: none;
}

.searchform input[type="submit"] {
background-color: #f70808;
-webkit-box-shadow: 0 2px 0 #c60606;
-moz-box-shadow: 0 2px 0 #c60606;
box-shadow: 0 2px 0 #c60606;
color: white;
border: none;
letter-spacing: 1px;
padding: 15px;
font-size: 15px;
text-align: center;
}

.searchform input[type="submit"],
.searchform input[type="text"] {
line-height: normal !important;
display: inline-block;
}

.my-fa {
font-family: 'FontAwesome';
position: absolute;
z-index: 2;
color: #f70808;
font-size: 2.8em;
margin-left: 4px;
top: 4px;
}

#slider-loading {
position: relative;
top: 12px;
right: 35px;
}


I want to show the map icon on the left of the input text field and and the loading spinner on the right of the input text field.

JSFiddle - with easyAutocomplete plugin

JsFiddle - without the plugin

Answer Source

You could add the following code to your CSS:

.easy-autocomplete{
    display:inline;
}

I think it gives you the desired outcome.

The plugin wraps the input in a div which by default have display:block and it throws the other elements out of line.

You may need to adjust the padding/margin to your preference.

See updated fiddle

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download