CSS content Property not working as expected in firefox - html

What i am doing is that in search box when user enter a search term, i display a close button ('x' character to be specific, embedded as content after reset button) to clear the contents of search box.
It works fine in both Chrome and IE but not in firefox.
Any kind of help would be highly appreciated.
.search-box,.close-icon,.search-wrapper {
position: relative;
padding: 10px;
}
.search-wrapper {
width: 500px;
margin: auto;
margin-top: 50px;
}
.search-box:focus {
box-shadow: 0 0 15px 5px #b0e0ee;
border: 2px solid #bebede;
}
.close-icon {
border:1px solid transparent;
background-color: transparent;
display: inline-block;
vertical-align: middle;
outline: 0;
cursor: pointer;
}
.close-icon:after {
content: "X";
display: block;
width: 15px;
height: 15px;
position: absolute;
z-index:1;
right: 35px;
top: 0;
bottom: 0;
margin: auto;
padding: 2px;
border-radius: 50%;
text-align: center;
color: black;
font-weight: normal;
font-size: 12px;
cursor: pointer;
}
.search-box:not(:valid) ~ .close-icon {
display: none;
}
<div class="search-wrapper">
<form>
<input type="text" name="focus" required class="search-box" placeholder="Enter search term" />
<button class="close-icon" type="reset"></button>
</form>
</div>

This code should help you
.search-box,.search-wrapper {
position: relative;
padding: 10px;
}
.search-wrapper {
width: 500px;
margin: auto;
margin-top: 50px;
}
.search-box
{
width:300px;
}
.search-box:focus {
box-shadow: 0 0 15px 5px #b0e0ee;
border: 2px solid #bebede;
}
.close-icon {
border:1px solid transparent;
background-color: transparent,
display: inline-block;
vertical-align: middle;
outline: 0;
position: absolute;
top:19px;
left:305px;
z-index:1;
padding: 1px 2px;
border-radius: 50%;
text-align: center;
color: black;
font-weight: normal;
font-size: 12px;
cursor: pointer;
}
.search-box:not(:valid) ~ .close-icon {
display: none;
}
<div class="search-wrapper">
<form>
<input type="text" name="focus" required class="search-box" placeholder="Enter search term" />
<button class="close-icon" type="reset">X</button>
</form>
</div>
NOTE : set your .search-box width and according to it set left of your .close-icon

Try this code: Hope this solve your problem. Adjust "outer_box" class for width.
<style>
.search-box, .search-wrapper {
padding: 10px;
box-sizing: border-box;
}
.search-box {
position:relative;
width:100%;
}
.outer_boxs{
position:relative;
width:60%;
}
.search-wrapper {
width: 500px;
margin: auto;
margin-top: 50px;
}
.search-box:focus {
box-shadow: 0 0 15px 5px #b0e0ee;
border: 2px solid #bebede;
}
.close-icon {
border:1px solid transparent;
background-color: transparent,
display: inline-block;
vertical-align: middle;
outline: 0;
cursor: pointer;
position: absolute;
right:5px;
top: 10px;
background:#f2f2f2;
}
.search-box:not(:valid) ~ .close-icon {
display: none;
}
</style>
<div class="search-wrapper">
<form>
<div class="outer_boxs" >
<input type="text" name="focus" required class="search-box" placeholder="Enter search term" />
<button class="close-icon" type="reset">X</button>
</div>
</form>
</div>

Related

How can you put a line inside a input?

I'm trying to build a input with a line inside of it in the middle. But I don't seem to know how to build it as the line always falls in the bottom but it gets inline with the button's border.
Here is what I've tried so far:
<div>
<input className={styles.replyInput} placeholder='Reply...' />
<div className={styles.grayLine}></div>
</div>
And here is the CSS:
.replyInput {
border: 2px solid #E0E0E0;
border-radius: 10px;
padding: 10px;
outline: none;
width: 100%;
}
.grayLine {
width: 80%;
margin-left: 5%;
position: absolute;
border: 1px solid #E0E0E0;
}
I'm trying to build this with CSS
You can use some approach like this
.mainDiv{
position:relative;
width: 80%;
padding: 2%;
height: 60px;
border: 2px solid #E0E0E0;
border-radius: 8px;
}
.replyInput {
outline: none;
border: none;
width: 100%;
}
.grayLine::after {
position: absolute;
width: 95%;
height: 1px;
content: "";
background: #E0E0E0;
margin-top: 10px;
}
.icons {
margin-top: 20px;
}
<div class='mainDiv'>
<input class='replyInput' placeholder='Reply...' />
<div class='grayLine'></div>
<div class='icons'>Some icons</div>
</div>
.replyInput {
display:block;
border: 2px solid #E0E0E0;
border-radius: 10px;
padding: 10px;
outline: none;
width: 100%;
}
.grayLine {
width: 80%;
top:50%;
position: absolute;
border: 1px solid #E0E0E0;
margin-left:20%;
}
#a{
position:relative;
}
<div id='a'>
<input class='replyInput' placeholder='Reply...' />
<div class='grayLine'></div>
</div>
Use <hr>
fieldset {
padding: 3px 6px;
border-radius: 10px;
border-color: #fefefe;
}
input {
display: inline-block;
width: 90%;
border: 0;
outline: none;
}
hr {
margin: 3px 0;
border-color: #fefefe;
}
menu {
margin: 0 0 0 -40px;
}
button {
border: 0;
background: transparent;
cursor: pointer;
}
.font::before {
content: '\f031';
font-size: smaller;
}
.font::after {
content: '\f031'
}
.contacts::before {
content: '#';
}
.emoticons::before {
content: '\f599'
}
.attach::before {
content: '\f0c6'
}
.send {
float: right
}
.send::before {
content: '\f1d8'
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" rel="stylesheet">
<fieldset>
<input id='reply' class='component' placeholder='Reply...'>
<hr>
<menu>
<button class='font fa' type='button'></button>
<button class='contacts fa' type='button'></button>
<button class='emoticons fa' type='button'></button>
<button class='attach fa' type='button'></button>
<button class='send fa' type='button' disabled></button>
</menu>
</fieldset>

Can't put icons into the search bar

I've only been doing HTML and CSS for a total of one month. I'm currently trying to replicate a Google search bar, but the problem is that I can't seem to fit the search icon and the voice icon inside the search bar. I've read that you're supposed to put the search bar's position as relative and the icons' as absolute, but I've apparently screwed up the code somewhere and can't figure it out. Thank you <3
My code (HTML and CSS):
input {
color: rgba(0,0,0,.87);
width: 600px;
padding: 15px;
border-radius: 50px;
border: 1px solid #dcdcdc;
outline-color: none;
cursor: text;
background-color: transparent;
z-index: -1;
}
input:focus {
outline: none;
}
input:hover {
box-shadow: 1px 1px 8px 1px #dcdcdc;
}
.voice {
height:20px;
top: 5px;
left: 10px;
position: absolute;
margin-right: 30px;
}
.search-icon {
color: rgb(154, 160, 166);
position: absolute;
z-index: 0;
}
.wrapper {
position: relative;
}
<form id="search-form">
<div class="wrapper">
<img class="search-icon" src="data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTkuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLi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z4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8L3N2Zz4K" />
<input class="search" type="text">
<img class="voice" src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e8/Google_mic.svg/716px-Google_mic.svg.png" title="Search by Voice">
</div>
</form>
So what you need to do is that it's not the text field that has the rounded corners and shadows, with the icons on top, but it's the wrapper that needs to have the rounded corners and borders and every, then the three elements all go inside of it.
so what I did is that I took your styles for the input, and moved it too the wrapper, then make the border:none, so the input is basically invisible.
then I removed all of your position styles because they aren't needed, so now we are basically done, except the elements are slightly off center, and the input doesn't fill the whole width.
I just decided to use display:flex on the wrapper, with flex-direction:row to make all of it horizontal, with align-items: center to center everything. I also added flex-grow:1 to the input so it fills the entire width.
input {
color: rgba(0,0,0,.87);
outline-color: none;
background-color: transparent;
border:none;
height:100%;
flex-grow:1;
font-size: 15px;
}
input:focus {
outline: none;
}
.voice {
height:20px;
margin: 0px 5px;
}
.search-icon {
color: rgb(154, 160, 166);
margin: 0px 5px;
}
.wrapper {
width: 600px;
height: 30px;
padding: 2px;
border-radius: 50px;
border: 1px solid #dcdcdc;
outline-color: none;
cursor: text;
background-color: transparent;
display:flex;
flex-direction: row;
align-items: center;
}
.wrapper:hover{
box-shadow: 1px 1px 8px 1px #dcdcdc;
}
<form id="search-form">
<div class="wrapper">
<img class="search-icon" src="data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTkuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iQ2FwYV8xIiB4PSIwcHgiIHk9IjBweCIgdmlld0JveD0iMCAwIDU2Ljk2NiA1Ni45NjYiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDU2Ljk2NiA1Ni45NjY7IiB4bWw6c3BhY2U9InByZXNlcnZlIiB3aWR0aD0iMTZweCIgaGVpZ2h0PSIxNnB4Ij4KPHBhdGggZD0iTTU1LjE0Niw1MS44ODdMNDEuNTg4LDM3Ljc4NmMzLjQ4Ni00LjE0NCw1LjM5Ni05LjM1OCw1LjM5Ni0xNC43ODZjMC0xMi42ODItMTAuMzE4LTIzLTIzLTIzcy0yMywxMC4zMTgtMjMsMjMgIHMxMC4zMTgsMjMsMjMsMjNjNC43NjEsMCw5LjI5OC0xLjQzNiwxMy4xNzctNC4xNjJsMTMuNjYxLDE0LjIwOGMwLjU3MSwwLjU5MywxLjMzOSwwLjkyLDIuMTYyLDAuOTIgIGMwLjc3OSwwLDEuNTE4LTAuMjk3LDIuMDc5LTAuODM3QzU2LjI1NSw1NC45ODIsNTYuMjkzLDUzLjA4LDU1LjE0Niw1MS44ODd6IE0yMy45ODQsNmM5LjM3NCwwLDE3LDcuNjI2LDE3LDE3cy03LjYyNiwxNy0xNywxNyAgcy0xNy03LjYyNi0xNy0xN1MxNC42MSw2LDIzLjk4NCw2eiIgZmlsbD0iIzAwMDAwMCIvPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8L3N2Zz4K" />
<input class="search" type="text">
<img class="voice" src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e8/Google_mic.svg/716px-Google_mic.svg.png" title="Search by Voice">
</div>
</form>
I also changed some padding and stuff slightly to make it work better but I guess that's optional
input {
font-size:20px;
width: 88%;
border:none;
margin-left:60px;
height:30px;
padding:0;
}
input:focus {
outline: none;
}
.wrapper:hover {
box-shadow: 1px 1px 8px 1px #dcdcdc;
}
.voice {
height:20px;
top: 10px;
left: 40px;
position: absolute;
margin-right: 30px;
}
.search-icon {
color: rgb(154, 160, 166);
position: absolute;
z-index: 0;
left: 15px;
top: 10px;
cursor:default;
}
.wrapper {
position: relative;
color: rgba(0,0,0,.87);
width: 600px;
padding:5px;
border-radius: 50px;
border: 1px solid #dcdcdc;
outline-color: none;
cursor: text;
background-color: transparent;
}
<form id="search-form">
<div class="wrapper">
<img class="search-icon" src="data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmUgSWxsdXN0cmF0b3IgMTkuMC4wLCBTVkcgRXhwb3J0IFBsdWctSW4gLiBTVkcgVmVyc2lvbjogNi4wMCBCdWlsZCAwKSAgLS0+CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgdmVyc2lvbj0iMS4xIiBpZD0iQ2FwYV8xIiB4PSIwcHgiIHk9IjBweCIgdmlld0JveD0iMCAwIDU2Ljk2NiA1Ni45NjYiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDU2Ljk2NiA1Ni45NjY7IiB4bWw6c3BhY2U9InByZXNlcnZlIiB3aWR0aD0iMTZweCIgaGVpZ2h0PSIxNnB4Ij4KPHBhdGggZD0iTTU1LjE0Niw1MS44ODdMNDEuNTg4LDM3Ljc4NmMzLjQ4Ni00LjE0NCw1LjM5Ni05LjM1OCw1LjM5Ni0xNC43ODZjMC0xMi42ODItMTAuMzE4LTIzLTIzLTIzcy0yMywxMC4zMTgtMjMsMjMgIHMxMC4zMTgsMjMsMjMsMjNjNC43NjEsMCw5LjI5OC0xLjQzNiwxMy4xNzctNC4xNjJsMTMuNjYxLDE0LjIwOGMwLjU3MSwwLjU5MywxLjMzOSwwLjkyLDIuMTYyLDAuOTIgIGMwLjc3OSwwLDEuNTE4LTAuMjk3LDIuMDc5LTAuODM3QzU2LjI1NSw1NC45ODIsNTYuMjkzLDUzLjA4LDU1LjE0Niw1MS44ODd6IE0yMy45ODQsNmM5LjM3NCwwLDE3LDcuNjI2LDE3LDE3cy03LjYyNiwxNy0xNywxNyAgcy0xNy03LjYyNi0xNy0xN1MxNC42MSw2LDIzLjk4NCw2eiIgZmlsbD0iIzAwMDAwMCIvPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8L3N2Zz4K" />
<input class="search" type="text">
<img class="voice" src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e8/Google_mic.svg/716px-Google_mic.svg.png" title="Search by Voice">
</div>
</form>
input {
color: rgba(0,0,0,.87);
width: 600px;
padding: 15px;
border-radius: 50px;
border: 1px solid #dcdcdc;
outline-color: none;
cursor: text;
background-color: transparent;
}
input:focus {
outline: none;
}
input:hover {
box-shadow: 1px 1px 8px 1px #dcdcdc;
}
.voice {
height:20px;
top: 10;
right: 40;
position: absolute;
margin-right: 30px;
}
.search-icon {
color: rgb(154, 160, 166);
position: absolute;
right:20;
top:10;
}
.wrapper {
width:600px;
position: relative;
}
<form id="search-form">
<div class="wrapper">
<img class="search-icon" src="data:image/svg+xml;utf8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pgo8IS0tIEdlbmVyYXRvcjogQWRvYmU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Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8Zz4KPC9nPgo8L3N2Zz4K" />
<input class="search" type="text">
<img class="voice" src="https://upload.wikimedia.org/wikipedia/commons/thumb/e/e8/Google_mic.svg/716px-Google_mic.svg.png" title="Search by Voice">
</div>
</form>

CSS3 : a div on text box

I have a textbox with having character limit box on it. What I want is. the text that is to be input should be upto the length of visible part of textbox.
I have tried this code.
.add_caption_div input[type="text"] {
border: thin #dee5e7 solid;
width: 190px;
border-top-left-radius: 0;
border-top-right-radius: 0;
display: inline-block;
float: left;
padding: 7px 12px;
}
.add_caption_div .image_galley_char_limit_div {
display: inline-block;
height: 31px;
width: 50px;
font-size: 9px;
color: #999999;
position: relative;
z-index: 100001;
background:#f6f8f8;
top:-6px;
right:51px;
}
.add_caption_div .form-control:focus {
border: thin #66afe9 solid;
}
.add_caption_div span {
position: relative;
top: 10px;
}
<div class="add_caption_div" >
<input type="text" class="form-control" placeholder="Enter Caption">
<div class="image_galley_char_limit_div text-center">
<span> 0/30</span>
</div>
</div>
When I type input then it goes behind the character_limit_div.
How can I prevent it?
Any help would be great.
Thank You.
.add_caption_div {
position: relative;
width: 190px;
}
.add_caption_div input[type="text"] {
border: thin #dee5e7 solid;
width: 190px;
border-top-left-radius: 0;
border-top-right-radius: 0;
display: inline-block;
float: left;
padding: 7px 12px;
}
.add_caption_div .form-control {
padding-right: 60px !important;
}
.add_caption_div .image_galley_char_limit_div {
display: inline-block;
height: 31px;
width: 50px;
font-size: 9px;
color: #999999;
position: absolute;
z-index: 100001;
top: 1px;
right: -73px;
background:#f6f8f8;
}
.add_caption_div .form-control:focus {
border: thin #66afe9 solid;
}
.add_caption_div span {
position: relative;
top: 10px;
}
<div class="add_caption_div" >
<input type="text" class="form-control" placeholder="Enter Caption">
<div class="image_galley_char_limit_div text-center">
<span> 0/30</span>
</div>
</div>
Is this the same that you are looking for?
Hope this helps.
you can give padding-right for input, something like this:
.add_caption_div input[type="text"] {
border: thin #dee5e7 solid;
width: 190px;
border-top-left-radius: 0;
border-top-right-radius: 0;
display: inline-block;
float: left;
padding: 7px 12px;
}
.add_caption_div .image_galley_char_limit_div {
display: inline-block;
height: 31px;
width: 50px;
font-size: 9px;
color: #999999;
position: relative;
z-index: 100001;
background:#f6f8f8;
top:-6px;
right:51px;
}
.add_caption_div .form-control:focus {
border: thin #66afe9 solid;
}
.add_caption_div span {
position: relative;
top: 10px;
}
.form-control{
padding-right: 70px !important;
}
<div class="add_caption_div" >
<input type="text" class="form-control" placeholder="Enter Caption">
<div class="image_galley_char_limit_div text-center">
<span> 0/30</span>
</div>
</div>

stop input breaking out of container

I am trying to have some pre-input on my forms and I want the input field to expand to the end of the container div. The problem is the input field seems to expand past the container div due to the length of the pre-input text.
.container {
width: 70%;
}
.input-field {
display: inline-block;
white-space: nowrap;
vertical-align: bottom;
background: #fff;
position: relative;
vertical-align: middle;
width: 100%;
min-width: 16px;
border: 1px solid #ddd;
}
.input-field .addon {
padding-left: 8px;
padding-right: 8px;
padding-top: 2px;
padding-bottom: 2px;
text-align: center;
text-shadow: 0 1px 0 #fff;
background: #f0f0f0;
}
.input-field input {
padding-left: 5px;
padding-top: 0;
padding-bottom: 0;
margin: 0;
border: 0;
outline: none;
background: transparent;
resize: none;
width: 100%;
}
.input-field:hover {
border: 1px solid #05c9f0;
}
<div class="container">
<div class="input-field">
<span class="addon">some preinput</span>
<input id="" type="text" name="" value="test text" />
</div>
</div>
Another example here: http://codepen.io/anon/pen/wgdErO
If you try the example code, you will note you can click the input box way outside where I want it to end.
Any thoughts on a fix?
Try using the flexbox layout.
.container {
width: 300px;
}
.input-field {
background: #fff;
border: 1px solid #ddd;
display: flex;
align-items: center;
}
.input-field .addon {
padding: 2px 8px;
text-shadow: 0 1px 0 #fff;
background: #f0f0f0;
}
.input-field input {
padding: 0 4px;
margin: 0;
border: 0;
outline: none;
background: transparent;
resize: none;
flex: 1;
}
.input-field:hover {
border: 1px solid #05c9f0;
}
<div class="container">
<div class="input-field">
<span class="addon">some preinput</span>
<input id="" type="text" name="" value="test text" />
</div>
</div>
<img src="//dummyimage.com/300x50">
Just decrease the input width from 100% to a lower value like 99.7% and that will do the trick:
.container {
width: 70%;
border: 1px solid red;
}
.input-field {
display: inline-block;
white-space: nowrap;
vertical-align: bottom;
background: #fff;
position: relative;
vertical-align: middle;
width: 99.7%;
min-width: 16px;
border: 1px solid #ddd;
}
.input-field .addon {
padding-left: 8px;
padding-right: 8px;
padding-top: 2px;
padding-bottom: 2px;
text-align: center;
text-shadow: 0 1px 0 #fff;
background: #f0f0f0;
}
.input-field input {
padding-left: 5px;
padding-top: 0;
padding-bottom: 0;
margin: 0;
border: 0;
outline: none;
background: transparent;
resize: none;
width: 100%;
}
.input-field:hover {border: 1px solid #05c9f0;}
<div class="container">
<div class="input-field">
<span class="addon">some preinput</span>
<input id="" type="text" name="" value="test text" />
</div>
</div>
You can calculate the width like this! width: calc(100% - 125px); rather than set it to 100%

How to insert an icon inside HTML `<input>` tag

Im not having sucess put my icon font inside my search input.
I already try with margin, padding, but nothing is working!
Can you give me a little help?
The fiddle with the problem:
http://jsfiddle.net/Tj7nJ/1/
My Html:
<li id="sb-search" style="float:right; list-style:none; height:20px; bottom:3px; ">
<form id="search">
<input name="q" type="text" size="40" placeholder="Pesquisar..." />
<button type="submit"><i class="fa fa-search"></i></button>
</form>
</li>
My css:
#search {
outline:none ;
border:none ;
}
#search button[type="submit"] {
width: 20px;
background:none;
cursor:pointer;
height:20px;
}
button[type="submit"]>i:hover
{
color: #fff;
}
button[type="submit"]>i
{
background:none;
color:#ccc;
font-size:1.1em;
}
#search input[type="text"]
{
border: 0 none;
background: #141d22;
text-indent: 0;
width:110px;
padding: 6px 15px 6px 35px;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
}
You can't put an image inside an <input type='text'> element.
However, you can remove the borders of the input with:
input[type='text'] {
background-color:transparent;
border: 0px solid;
}
and then wrap it with the icon inside a div and re-style.
Example code:
Here is a jsFiddle for you: http://jsfiddle.net/hxjY7/
Here is the code:
<style type="text/css">
#textBoxWrapper{
border: 1px solid black;
width: 172px;
height: 20px;
}
#textBox {
background-color:transparent;
border: 0px solid;
width: 150px;
height: 20px;
float:left;
}
#icon{
width: 20px;
height: 20px;
background-color: grey;
float:left;
}
</style>
<div id="textBoxWrapper">
<div id="icon"></div>
<input type="text" id="textBox" />
</div>
If you are trying to move the button inside the input field, you could set the button to position absolute (and the search wrapper to relative):
http://jsfiddle.net/Tj7nJ/3/
#search {
outline: none;
border: none;
}
#search {
position: relative;
z-index: 1;
}
#search button[type="submit"] {
width: 20px;
background: none;
cursor: pointer;
height: 20px;
z-index: 2;
position: absolute;
top: 3px;
right: 10px;
}
button[type="submit"]>i:hover {
color: #fff;
}
button[type="submit"]>i {
background: none;
color: #ccc;
font-size: 1.1em;
}
#search input[type="text"] {
border: 0 none;
background: #141d22;
text-indent: 0;
width: 110px;
padding: 6px 15px 6px 35px;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
border-radius: 20px;
}
I think this is what you are trying to do. jsFilddle
HTML:
<form id="search" action="#" method="post">
<fieldset>
<input type="text" id="q" name="q" size="40" placeholder="Search..." />
<button type="submit"><i class="fa fa-search"></i>
</button>
</fieldset>
</form>
CSS:
form#search fieldset {
position: relative;
border: none;
}
form#search input[type='text'] {
padding: 4px;
}
form#search button {
position: absolute;
top: 9px;
left: 262px;
}