Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting an Input Box Background

I have to create an input box with the following background

enter image description here

So far in my code I have the code below and its not showing -> What would be the correct procedure to do this?

I also have a couple of variations of this button I have to produce and they are the following:

  • A cross on the dark area of the button - I was just going to use a <span> tag with a class and set the graphic to that -> Would this be a good way to go?

  • A paper clip icon just after the curve on the left -> I was going to do the same as above -> Would this be a good way to go?

HTML:

<div class="innerTo">
        <form action="#" method="get">
           <label for="recipients">TO: </label>
              <input type="search" name="recipients" id="recipients" placeholder="Recipients Names">
    </form>
    </div>

CSS:

.innerBar .innerTo{
    width:200px;
    padding:5px 0 0 15px;
    display:block;
    float:left;
}
.innerBar .innerTo label{
    margin:0 15px 0 0;
    font-size:14px;
    font-weight:bold;
    color:#666666;
}
.innerBar .innerTo input[type=search] {
    color: red;
}
.innerBar .recipients{
    background-image:url('../images/searchBGpng.png') no-repeat;
    width:192px;
    height:27px;
}
like image 769
Jess McKenzie Avatar asked Jun 01 '12 03:06

Jess McKenzie


1 Answers

Fiddled:

<div class="input-container">
    <input type="text" value="aaaaaaaaaaaaaaaaaa"/>
</div>

.input-container {
    background: url(http://i.stack.imgur.com/0Vlc5.png) no-repeat;
    width:197px;
    height:28px;
}
.input-container input{
    height:28px;
    line-height:28px;/*results in nice text vertical alignment*/
    border:none;
    background:transparent;
    padding:0 10px;/*don't start input text directly from the edge*/
    width:148px;/*full width - grey on the side - 2*10px padding*/
}

If you're planning to reuse it with different widths, you should look up the sliding doors technique.

like image 119
Oleg Avatar answered Oct 06 '22 19:10

Oleg