Reputation: 403
I can't figure out what's causing the blank space between the submit button and the input area of the searchbox.
https://i.sstatic.net/2DuDq.png
html:
<form method="get" id="searchform" action="<?php bloginfo('url'); ?>">
<p><input type="text" class="field" name="s" id="s" placeholder="Search" />
<input type="submit" class="submit" name="submit" value="Traži" /></p>
css:
#searchform {
float: right;
padding-top: 10px;
position: relative;
}
header input#s {
margin: 0;
border: none;
height: 29px;
width: 250px;
}
header input:active {
border: none;
}
header input.submit {
border: none;
height: 30px;
width: 30px;
margin: 0;
text-indent: -99999px;
background: white url(images/search.png) 0 0 no-repeat;
padding-right:20px;
}
Upvotes: 2
Views: 13600
Reputation: 446
This is one from the most frequently questions, it's very important to have a nice search bar with a good look, you did a nice work ,but the best way to create a better search bar is like that, follow me step by step it will helps you a lot, the look you want in a short time :
you create the form tag and inside you create a div with class expl : searchBarContainer
inside your div you create an input:text and button don't use input:btn // now you have a form / div / input text and button
<form method="get" action="">
<div class="searchBarContainer">
<input type="text" class="searchBox" name="s" id="s" placeholder="Search" />
<button class="btn-search">
<img src="search-icn.png" >
</button>
</div>
now we have the structure and we need just a style for our form it looks ugly right ? of course it is, so :
.searchBarContainer {
border: none;
height: 2.5rem;
background-color: #fff;
border-radius: 2px;
box-shadow: 0 2px 2px 0 rgba(0,0,0,0.16),0 0 0 1px rgba(0,0,0,0.08);
box-sizing: border-box;
width: 20%;
max-width: 60%;
display: flex; /* <===== the most iportant line in this code */
}
in this code dyplay flex all that you need to focus on :
display : flex;
felx : 1;
.searchBarContainer .searchBox {
flex : 1; /* <===== the most iportant line in this code */
font-size: 14px;
color: #000;
border: none;
}
And last for the button style :
.btn-search {
border: none;
background-color: #fff;}
Final Result
Upvotes: 1
Reputation: 13
.sidebar.widget-area .widget.widget_search .search-form .search-submit {
position: absolute;
padding: 0 19px;
background-image: url(assets/images/search.png);
border: 0;
background-color: transparent;
right: 0px;
top: 29px;
color: #7a7a7a;
cursor: pointer;
font-size: 0px;
height: 17px;
width: 10px;
background-repeat: no-repeat;
}
Upvotes: 0
Reputation: 5395
http://jsfiddle.net/butuzov/MCtc3/
use font-size:0 for parent element (p in your case) or avoid space between input element
Upvotes: 4