How do I post an image inside of a search box? - css

I am trying to get an image inside of the following search box:
<input class="search" type="text" name="q" id="q" size="70" maxlength="2048" style= "display:block; position:relative; left:35.5%; bottom:-3px; height:2em;">
</input>
When I try to direct the mic image to go inside of the search box, it ends up disappearing behind the box. Does anyone know how to place this image inside of the search box without it vanishing?
Here is the fiddle for it: https://jsfiddle.net/gLvzdj0n/3/

Check out this Jsfiddle link
HTML code:
<div class="wrap left rounded">
<input type="text" class="search left rounded" value="Search for dishes or restaurants" />
<button class="go left rounded"><span></span></button>
</div>
CSS code:
.left {
float:left;
}
.rounded {
-webkit-border-radius:5px;
-moz-border-radius:5px;
border-radius:5px;
}
.wrap {
position:relative;
padding:5px 6px 6px 7px; /* readjust in jsfiddle*/
background:#f0f0f0;
border:1px solid #ccc;
overflow:hidden;
}
.search {
width:360px;
position:relative; top:2px; /* readujst in jsfiddle */
padding:8px 5px 8px 30px;
border:1px solid #ccc;
background:white url(http://i.imgur.com/lFkqn.png) left center no-repeat;
}
.go {
position:relative; top:0;
padding:3px 5px 2px;
margin-left:8px;
border:none;
background: -webkit-gradient(linear, left top, left bottom, from(#d631a7), to(#8f1b64));
background: -moz-linear-gradient(top, #d631a7, #8f1b64);
}
.go span {
display:block;
width:64px; height:28px;
background:url(http://i.imgur.com/mxxzQ.png) 0 0 no-repeat;
}

You can solve this problem by css (position)
as the following:
<div id="MyDiv" style="position: absolute;">
<img src="img/clearSearchbutton.png" id="imgInInput" style="position: absolute;">
</div>
then give your div style like margin or padding to put your image inside input
Note if you need 'X' button just do this
<input class="search" type="search" name="q" id="q" size="70" maxlength="2048" style= "display:block; position:relative; left:35.5%; bottom:-3px; height:2em;">
</input>

you can remove #mic span and apply mic to input background.
see jsfiddle below
Demo Jsfiddle
change your css like below
.search {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAACrElEQVR42u2Xz2sTQRSAX8VSb1K8iNqKooJH2Ux6Ksn+iPQqxZMIehJB0do/IMhmQWsvHr2KSEGk0tSLIoWIYNUKij20F2/N7iaUZnYT0kYzzhMKs0HDJiTdLcwHDwKZSd63781LBiQSSW9JZdkhzfKm1Rz9mjZp/W9YdEU3vXv4HsQZ40FtNG36q5rls//Ej4tmbSS2T15Mvp3ExOPmEMQNbBtMMEyoljcFcQN7PqyAlqNfIG7gYQ0tYNIaxA1MrJPY3wImbUqBKAXSFv0tBSIVMOkvKRDtGKWN/T6FdqRAxFNoWwpEPIXqUqBT6ALU/UVgu8GW4GD3f6f9TRDYNJTDrk7YbtiqUumHwIYoUJuHERDAS0r4CvgFECgbY+cFAR7KT+g1POmCKFDNw6WggHc3fBtVb4CAoyauBgXIG+g1Xh5mRAGah6cggBd11fK/h7lOprIs0H6uRl6KAo5O7kOv4QmPiwJ4Jqqv4FiwCtXjvD2+tRmfK6kZ/ygI2HritK0rDVGgrClJ6DWMwYC/AGuCBMYcIC2V0CzvjmbRz3j3xUjn6CfeYreUJ2wQkGD75INPX1mFfsEFrrcIYCvdhC4paWQakxajpJMr0C9YFg54i7AsClRmh9/xnr0NHcInzZStk2aLwAcGMAD9pPIazvFKVDD5rdnhJeHLX5RTyRPQHpz5o66emMc9wdlPtvA8wF7Aq2BUHh1525qEo5JtR1WeOXpickO9cJIpyuD6xJmhYiZ5ytWSl3mlnuOaf+2zDaLDXmJrSgZ/MYVEugo+gSh+FkSBa4yd5Ul87DZ5XpFl/AyIEjzYjkau8WqshU2cr13HPbgX4gJOD97n465GZlyVvC9mSKloKI2iTnbwNT+gBX54H+IaXAtxJzE3ycSAFqSAFJACUkAikXD+AHj5/wx2o5osAAAAAElFTkSuQmCC");
background-position: right center;
background-repeat: no-repeat;
background-size: 24px 24px;
}

Check this out.
I had edited your fiddle.
#mic {
background-position: -2.99999976158142px 0px;
color: rgb(17, 34, 204);
cursor: pointer;
display: block;
height: 22.9861125946045px;
vertical-align: middle;
white-space: nowrap;
width: 16.9965286254883px;
perspective-origin: 8.48958396911621px 11.4930562973022px;
transform-origin: 8.48958396911621px 11.4930562973022px;
background: rgba(0, 0, 0, 0) url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAACrElEQVR42u2Xz2sTQRSAX8VSb1K8iNqKooJH2Ux6Ksn+iPQqxZMIehJB0do/IMhmQWsvHr2KSEGk0tSLIoWIYNUKij20F2/N7iaUZnYT0kYzzhMKs0HDJiTdLcwHDwKZSd63781LBiQSSW9JZdkhzfKm1Rz9mjZp/W9YdEU3vXv4HsQZ40FtNG36q5rls//Ej4tmbSS2T15Mvp3ExOPmEMQNbBtMMEyoljcFcQN7PqyAlqNfIG7gYQ0tYNIaxA1MrJPY3wImbUqBKAXSFv0tBSIVMOkvKRDtGKWN/T6FdqRAxFNoWwpEPIXqUqBT6ALU/UVgu8GW4GD3f6f9TRDYNJTDrk7YbtiqUumHwIYoUJuHERDAS0r4CvgFECgbY+cFAR7KT+g1POmCKFDNw6WggHc3fBtVb4CAoyauBgXIG+g1Xh5mRAGah6cggBd11fK/h7lOprIs0H6uRl6KAo5O7kOv4QmPiwJ4Jqqv4FiwCtXjvD2+tRmfK6kZ/ygI2HritK0rDVGgrClJ6DWMwYC/AGuCBMYcIC2V0CzvjmbRz3j3xUjn6CfeYreUJ2wQkGD75INPX1mFfsEFrrcIYCvdhC4paWQakxajpJMr0C9YFg54i7AsClRmh9/xnr0NHcInzZStk2aLwAcGMAD9pPIazvFKVDD5rdnhJeHLX5RTyRPQHpz5o66emMc9wdlPtvA8wF7Aq2BUHh1525qEo5JtR1WeOXpickO9cJIpyuD6xJmhYiZ5ytWSl3mlnuOaf+2zDaLDXmJrSgZ/MYVEugo+gSh+FkSBa4yd5Ul87DZ5XpFl/AyIEjzYjkau8WqshU2cr13HPbgX4gJOD97n465GZlyVvC9mSKloKI2iTnbwNT+gBX54H+IaXAtxJzE3ycSAFqSAFJACUkAikXD+AHj5/wx2o5osAAAAAElFTkSuQmCC) no-repeat scroll -2.99999976158142px 0px / 23.9999980926514px 23.9999980926514px padding-box border-box;
border: 0px none rgb(17, 34, 204);
font: normal normal normal normal 16px/38px arial, sans-serif;
outline: rgb(17, 34, 204) none 0px;
right: 10px;
top: 15px;
position: absolute;
}
/*#SPAN_1*/
<input class="search" type="text" name="q" id="q" size="70" maxlength="2048" style="display:block; position:relative; left:35.5%; bottom:-3px; height:2em;">
</input>
<span id="mic"></span>

Try this link and I think that is what you want
http://codepen.io/rafibomb/pen/rFgcI?editors=101
placing an image inside search box.

Keep it SIMPLE!
All you need to do is just put your stuff in a container div like this:
<div style="width:50px; height:20px; position:absolute;">
<input class="search" type="text" name="q" id="q" size="70" maxlength="2048" style= "display:block; position:relative; left:35.5%; bottom:-3px; height:2em; z-index:1;">
</input>
<span id="mic"></span>
</div>
Remove left and bottom (they are not much needed) from your input box and ADD position:absolute;.
This is the CSS for your <input>:
display: block;
height: 2em;
width: 100%;
position: absolute;
And now Remove margin-left:800px; and ADD position: absolute; , right: 0px; and margin-top: 4px;. Here is the CSS for your <span>
color: #12C;
cursor: pointer;
display: block;
vertical-align: middle;
white-space: nowrap;
width: 16.9965px;
border: 0px none #12C;
outline: 0px none #12C;
height: 22.9861px;
background: transparent url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAACrElEQVR42u2Xz2sTQRSAX8VSb1K8iNqKooJH2Ux6Ksn+iPQqxZMIehJB0do/IMhmQWsvHr2KSEGk0tSLIoWIYNUKij20F2/N7iaUZnYT0kYzzhMKs0HDJiTdLcwHDwKZSd63781LBiQSSW9JZdkhzfKm1Rz9mjZp/W9YdEU3vXv4HsQZ40FtNG36q5rls//Ej4tmbSS2T15Mvp3ExOPmEMQNbBtMMEyoljcFcQN7PqyAlqNfIG7gYQ0tYNIaxA1MrJPY3wImbUqBKAXSFv0tBSIVMOkvKRDtGKWN/T6FdqRAxFNoWwpEPIXqUqBT6ALU/UVgu8GW4GD3f6f9TRDYNJTDrk7YbtiqUumHwIYoUJuHERDAS0r4CvgFECgbY+cFAR7KT+g1POmCKFDNw6WggHc3fBtVb4CAoyauBgXIG+g1Xh5mRAGah6cggBd11fK/h7lOprIs0H6uRl6KAo5O7kOv4QmPiwJ4Jqqv4FiwCtXjvD2+tRmfK6kZ/ygI2HritK0rDVGgrClJ6DWMwYC/AGuCBMYcIC2V0CzvjmbRz3j3xUjn6CfeYreUJ2wQkGD75INPX1mFfsEFrrcIYCvdhC4paWQakxajpJMr0C9YFg54i7AsClRmh9/xnr0NHcInzZStk2aLwAcGMAD9pPIazvFKVDD5rdnhJeHLX5RTyRPQHpz5o66emMc9wdlPtvA8wF7Aq2BUHh1525qEo5JtR1WeOXpickO9cJIpyuD6xJmhYiZ5ytWSl3mlnuOaf+2zDaLDXmJrSgZ/MYVEugo+gSh+FkSBa4yd5Ul87DZ5XpFl/AyIEjzYjkau8WqshU2cr13HPbgX4gJOD97n465GZlyVvC9mSKloKI2iTnbwNT+gBX54H+IaXAtxJzE3ycSAFqSAFJACUkAikXD+AHj5/wx2o5osAAAAAElFTkSuQmCC") no-repeat scroll -3px 0px / 24px 24px;
position: absolute;
right: 0px;
perspective-origin: 8.48958px 11.4931px;
transform-origin: 8.48958px 11.4931px 0px;
margin-top: 4px;
Hope this resolves your issue.
P.S.Whatever CSS i have mentioned in this is an update of your present link of JSFiddle.

Related

Center button in MailChimp

Hello,
How can I center a MailChimp button? The button is centered on desktop, but is shifted right on mobile devices, see the picture. I have been trying playing around with some classes and id's but can not solve it really. Not all the CSS code is necessary I guess. Sorry, I know it is messy. (In the HTML I have HIDDEN... the API-key)
Here is the HTML:
<!-- Begin Mailchimp Signup Form -->
<div id="mc_embed_signup">
<form id="mc-embedded-subscribe-form" class="validate" action="https://hotmail.us4.list-manage.com/subscribe/post? HIDDEN... " method="post" name="mc-embedded-subscribe-form" novalidate="" target="_blank">
<div id="mc_embed_signup_scroll">
<span class="text1">Ta del av vårt nyhetsbrev!</span>
<input id="mce-EMAIL" class="email" name="EMAIL" required="" type="email" value="" placeholder="Skriv din e-post här!" />
<!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
<div style="position: absolute; left: -5000px;" aria-hidden="true"><input tabindex="-1" name=" HIDDEN...
" type="text" value="" /></div>
<div class="clear">
<center><input id="mc-embedded-subscribe" class="button2" name="subscribe" type="submit"
value="Prenumerera" />
</center>
</div>
</div>
</form></div>
<!--End mc_embed_signup-->
Here are some CSS:
.button2 {
display: inline-block;
text-align: center;
font-family: lora !important;
/* vertical-align: bottom;*/
/* padding-bottom: 0px !important;*/
margin:auto !important;
height:34px !important;
line-height :34px !important;
padding: 5px 12px !important;
border: 1px solid #aeb11b;
border-radius: 8px;
background: #f8fd27!important;
background: -webkit-gradient(linear, left top, left bottom, from(#f8fd27), to(#aeb11b))!important;
background: -moz-linear-gradient(top, #f8fd27, #aeb11b)!important;
background: linear-gradient(to bottom, #f8fd27, #aeb11b)!important;
-webkit-box-shadow: #8d1bb3 0px 0px 24px 0px!important;
-moz-box-shadow: #8d1bb3 0px 0px 24px 0px!important;
box-shadow: #8d1bb3 0px 0px 24px 0px!important;
text-shadow: #ffff33 1px 1px 1px!important;
font: normal normal bold 20px arial!important;
color: #111111!important;
text-decoration: none!important;
}
.button2:hover,
.button2:focus {
border: 1px solid #f8fd27!important;[![enter image description here][1]][1]
background: #ffff2f!important;
background: -webkit-gradient(linear, left top, left bottom, from(#ffff2f), to(#d1d420))!important;
background: -moz-linear-gradient(top, #ffff2f, #d1d420)!important;
background: linear-gradient(to bottom, #ffff2f, #d1d420)!important;
color: #111111!important;
}
.button2:active {
background: #aeb11b!important;
background: -webkit-gradient(linear, left top, left bottom, from(#aeb11b), to(#aeb11b))!important;
background: -moz-linear-gradient(top, #aeb11b, #aeb11b)!important;
background: linear-gradient(to bottom, #aeb11b, #aeb11b)!important;
}
.button2:after{
content: "\0000a0"!important;
display: inline-block!important;
height: 24px!important;
width: 24px!important;
line-height: 24px!important;
margin: 0 -4px -6px 4px!important;
position: relative!important;
top: 0px!important;
left: 0px!important;
background: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAEJUlEQVRIiaWVXWhURxTHf3P3Zjfq5mOzZE1q1RC1Eb+yxhbBB6lN+yD40BJRUGlAUKIIRTEVn3wzfbFQqiJVH4rFL2qRih8VYkWxtCUSimWLYDS1Jm52UzfG3N17786d6UOycVc3Ee3AwHyc+f/OOcOcEYBBkTbv3Xms/mx1feX0ynWlpaXNU3xTFgSnBiNKKTlijwzanh2zM3ZnaiB19vwX53sfxR4Vk0GMAVQ+qO1EW324NtyxsHbhx0siS8xZ5bPw+/worQAwhIHlWvQ87aE73i17k70/pOKpvUc+PXI/T0cBRj4AwNh+bvumurfqDi2rXRYESGQSDNlDZFUWpRUCgSEMAmaAUGmIyNQIz5xndPV3DSeSiW2HWw6fznNYFUSw5dyWz8tCZR3VU6uLhjtZ87RHMp3EGrLaj7Uc+zLndA7AhpMbNgWrgt9WlFYQLAm+NgBgMDOIIx1GnoxsPLnh5OlxwJpDa+orZ1Z2C58IVgYqKfOXvREgmUliSxvt6eHUw1TjxR0Xe81INIJZZXY42gkiYVAN4vf5EYjxgzPKZrBq5iqEGF27PXCb2GCsQNxVLkP2UG5abobNjoq5FRt9S9uXzimpKjkotTSkkriei5W18Pv8aDSe9njqPCVUGmLl2yupmVbDovAi+qw++q1+PO1hZS36RvpwPRepJFJJlKHml88p/843e/3sNl2iP8ptSCWxpU3KTuF4DhoNAu4P3cf1XOZXzcdn+FhcvZh7qXt0J7oZSA8UiEslkVoaylD9pivcZk96RXNqZS3iVhyAEqOEu6m7xK04bdE2TGGyLbqNx9Zjbj66WfS8Z3jNovGbxsdGwKjJ31gxYwWhQGjCy2x5p4VoJAqA4znsvbGX6/9cf8lOOapfNBxt8IQhCsrFqTWnaKxuRAiB1hpg0rHruez8eSfXHl4rAGipXdOW9kvVKFcSciKvGiutSGfTZGTmRQBm2k4nhF8UpOhA1wHCU8JF0yMQtC5spWl6EwAZmWHrT1u5+vfVl2y1qxOmLe0YBgWACz0XiooD7Fq2i2gkitYax3NovdzKlQdXihtLYmbGznRi8MGEinmet7/Xzr4V+4DRy113YR2XH1ye+FCGTsFO5jKdvxCYkwH2LN/D/pX7MYRBJpth/Y/rJ40UjSROg6Aeg02cIcDaiWybaprYvXz3ePk48ecJLvVcmswfcDjNcTaOVtMd1BHmDwRvVkZfbIph/qWRQ/T6AMHvPKGJPkw+QcH/7s/YzNfcAsQoADS/coel2Bh8iH5DYQ9I085XHM3F8hwAmt/4hSXcG4MEXktcMozFZg5ydGxFA+QDRt9zF3eYyxkMatE0oDBe4bXE4Swp1nKcW2Oei1x/8dNnfF6LwfvUM421+GgGFmAQQaPQJIAYHp2M8D2d9JJ8/tHn6/wHNkwY75YHNyEAAAAASUVORK5CYII=") no-repeat left center transparent!important;
background-size: 100% 100%!important;
}
#mc-embedded-subscribe {
font-family:lato !important;
text-transform: none !important;
}
.validate {
text-transform: none !important;
font-family: helvetica;
font-weight:700 !important;
width: 100% !important;
text-align: center !important;
font-size: 19px !important;
line-height: 30px;
font-style: normal;
}
#mc-embedded-subscribe-form,
#mc_embed_signup {
padding: 0px 0px !important;
margin: 0px 0px !important;
}
.mc_embed_signup_scroll,
.mc-embedded-subscribe
.validate
.clear {
position: absolute;
padding: 0px 0px !important;
margin: 0px 0px !important;
left: 50%;
font-family: arial !important;
top: 10%;}
#mc_embed_signup input.email {
height:35px !important;
width: 220px;
}
Your code snippet provided is working just fine.
Problem is that in your page, that you provided in comment, there is float: right declared on your button which I saw by inspecting that element:
input[type=submit], button, input[type=button] {
border: none;
text-transform: uppercase;
margin: 10px 0px 0px;
padding: 11px 20px;
float: right;
...
}
Removing it fixed the issue.
One more thing. Try not to use <center> tag as it is not supported by HTML5
Since you are using WordPress theme that is maybe not editable, add internal or inline style float: none to your HTML page:
Internal style:
<head>
<style>
input[type=submit], button, input[type=button] {
float: none;
}
</style>
</head>
Inline style
<input id="mc-embedded-subscribe" class="button2" name="subscribe" type="submit"
value="Prenumerera" style="float: none"/>
To inspect an element:
Go to your website page
Right click on button
Left click on "Inspect element"
You will see HTML of your page and next to that CSS. Scroll down to see the code that I provided in my answer.

Text disappeared from buttons

I am trying to have it so users can log in into my website using fb etc. For some reason, the text gets hidden behind the buttons in my existing code. I am not sure what's wrong since the text used to show up where it needed to be up until I changed the background of the buttons and added social icons to them. Could you please help?
Here is the relevant code:
HTML:
<a class="alt-sign-in facebook">Login with facebook</a>
<a class="alt-sign-in google">Login with google</a>
<a class="alt-sign-in twitter">Login with twitter</a>
<form>
<input type="text" name="name" placeholder="name">
<input type="text" name="email" placeholder="email">
<input type="submit" name="submit">
</form>
<button id="computer-button">Start</button>
</div>
CSS:
#import url('http://weloveiconfonts.com/api/?family=entypo');
#import url('http://weloveiconfonts.com/api/?family=zocial');
html, body {
height: 100%;
background: #ddd;
}
.alt-sign-in {
position: relative;
display:block;
height: 40px;
width: 300px;
margin: 10px 0px auto auto;
padding: 5px;
font: 700 16px/40px'Quattrocento Sans', sans-serif;
text-decoration: none;
text-transform: uppercase;
text-align:center;
line-height: 40px;
color: #555;
border-radius: 2px;
background: linear-gradient(to bottom, white 40%, lightgrey);
box-shadow: 0 1px 1px rgba(0, 0, 0, .5);
cursor: pointer;
box-sizing: border-box;
}
.alt-sign-in:before {
color:white;
position:relative;
top: -5px;
left: -5px;
display:block;
box-sizing: border-box;
height: 40px;
width: 45px;
font: 20px/40px entypo;
text-align: center;
color: #fff;
border-radius: 2px 0 0 2px;
}
http://jsfiddle.net/prettysweet/Dv9rC/24/
Thank you so much!
The code you have posted seems to be an incomplete, or older version.
But by judging from your jsfiddle link, I suggest to change the following;
.alt-sign-in {
/* removed: box-sizing: border-box; */
}
.alt-sign-in:before {
position:absolute;
top: 5px;
left: 5px;
}
see http://jsfiddle.net/Dv9rC/27/
I think you have floating element problem. If you add these lines to your css code, it'll be OK.
.alt-sign-in.facebook:before {
...
float: left;
}
.alt-sign-in.google:before {
...
float: left;
}
.alt-sign-in.twitter:before {
...
float: left;
}
Bonus Edit: After adding all of these codes, just add form tag to your CSS document for top margin.
form{
margin-top:15px;
}

changing the Style of Radio buttons in jQuery mobile 1.4.0

I have the Following Radio buttons in my jQuery mobile app , I need to style them as the Radio button in the image bellow . I have tried the following css but it didn't give me the same result , Please Help me ..
Html
<div data-role="page">
<div data-role="header" data-theme="b" style="height:63px;">
</div>
<div data-role="content">
<form>
<fieldset>
<input type="radio" id="Male" value=" Male" name="radio-group-1" />
<label for="Male" data-inline="true" style="background:transparent !important;">Male </label>
<input type="radio" id="Female" value=" Female" name="radio-group-1" />
<label for="Female" data-inline="true" style="background:transparent !important;" >Female </label>
</fieldset>
</form>
</div>
</div>
CSS
input[type="radio"] {
display: none;
}
.ui-btn.ui-radio-off:after, .ui-btn.ui-radio-on:after{
width: 25px;
height: 25px;
}
.ui-btn.ui-radio-off:after, .ui-btn.ui-radio-on:after{
margin-top: -18px;
margin-left: -38px;
}
.ui-btn.ui-radio-on:after{
width: 55px;
height: 55px;
background: green !important;
background-size:100px 24px;
}
This is what i get
To get a green inner circle with transparent around it and a border after that, you really need 2 circles. This could be achieved by adding a :before element as well as the :after element in CSS.
Here is a DEMO
The CSS makes the whole button 56px tall and vertically centers the text by making the line-height the same. When off, the radio image is 26x26 with a gray border. When on, the :before css adds a new 26x26 empty circle with a border while the :after css creates a smaller green circle in the center. NOTE: you may need to tweak sizes and margins to get your desired results.
input[type="radio"] {
display: none;
}
.ui-radio label {
height:56px;
line-height: 56px;
padding-left: 50px;
}
.ui-radio .ui-btn.ui-radio-off:after {
background-image: none;
width: 26px;
height: 26px;
border: 2px solid #6E7983;
margin-top: -13px;
}
.ui-radio .ui-btn.ui-radio-on:after {
background-color: #86D51C;
width: 14px;
height: 14px;
margin-top: -6px;
margin-left: 10px;
border: 0;
}
.ui-radio .ui-btn.ui-radio-on:before {
content:"";
position: absolute;
display: block;
border: 2px solid #6E7983;
border-radius: 50%;
background-color: transparent;
width: 26px;
height: 26px;
margin-top: 14px;
margin-left: -39px;
}

Textbox with search icon placement

I am not very good at CSS, the textbox has been aligned to right, I tried putting the search icon into the textbox, it just can't go in. Here are the code:
<style type="text/css">
#textbox-search{overflow:auto;}
#textbox-search input.searchkeyword {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
border:1px solid #8e8e8e;
background-color:#f5f5f5;
height:16px;
padding:-4px;
padding-left:-48px;
color:#4a4a4a;
float:right;
}
#textbox-search input.button{
border:0;
padding:4px;
margint:0 0 0 600px;
width:24px;
height:24px;
background:transparent url('images/search.png') center center no-repeat;
float:right;
}
</style>
<form id="textbox-search">
<input type="submit" class="button" value="" />
<input type="text" class="searchkeyword" />
</form>
UPDATE :
You can simply achieve this using background property like this
input{
background: url("http://png.findicons.com/files/icons/1389/g5_system/32/toolbar_find.png") top right no-repeat;
height:30px;
padding-right:30px;
}
JS Fiddle Demo
You can change Height and padding value as per your image dimension.
you can easily do this
.searchkeyword {
width: 100%; /*textbox width*/
float: none;
background: url(your_image.png);
background-size: 20px 20px;/*background icon size*/
background-repeat: no-repeat;
background-position: 8px 10px; /*place where you wnat*/
display: block;
text-indent: 20px; /*help to indent your text on textfield*/
}

positioning a div inside another div?

In a big div I have search box which basically is a div having text box glass image and button. Requirement is to positioned this search wizard vertically in middle and on right side in div. This box is coming on top left inside div. I have tried different things but not getting how to set it. Please guide me.
Thanks
<div class="Right">
<div class="header-search" style="position: relative; top: auto; bottom: auto; right: 0 left:100%;
margin: auto 0 auto auto;">
<input type="text" class="searchbox" />
<input type="button" class="searchbutton" value="›" />
</div>
</div>
div.Container div.Right
{
width:50%;
float:right ;
border: 01px dashed green;
height:95px !important;
padding:auto 0 auto 200px;
}
div.header-search
{
overflow:auto;
display:inline;
text-align:right !important;
border:3px dashed blue;
padding:20px 0 auto 50px;
}
div.header-search input.searchbox
{
border-bottom-left-radius:5px;
-webkit-border-bottom-left-radius:5px;
-moz-border-bottom-left-radius:5px;
border-top-left-radius:5px;
-webkit-top-left-radius:5px;
-moz-left-radius:5px;
border:2px solid #316200;
background-color:white;
height:16px;
padding:4px;
padding-left:28px;
padding-right:10px;
color:#4a4a4a;
float:left;
background:white url(../images/SearchImage.png) 0 50% no-repeat;
}
div.header-search input.searchbutton
{
border-bottom-right-radius:5px;
-webkit-border-bottom-right-radius:5px;
-moz-border-bottom-right-radius:5px;
border-top-right-radius:5px;
-webkit-top-right-radius:5px;
-moz-right-radius:5px;
background:#458A00;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#A5D376', endColorstr='#326400'); /* for IE */
background: -webkit-gradient(linear, left top, left bottom, from(#A5D376), to(#326400)); /* for webkit browsers */
background: -moz-linear-gradient(top, #A5D376, #326400); /* for firefox 3.6+ */
width:50px;
height:28px;
color:White;
font-size:16px;
font-weight:bold ;
border:2px solid #316200;
border-left:none;
}
The first step in understanding how positioned elements is reading an article like this one:
CSS-Tricks.com - absolute positioning inside relative positioning
you are using position: relative on the wrong div as it should be assigned to .Right- while header-search should have instead 'position: absolute;' and values for left/right and top/bottom
the article above explains it much better than I could ever do!
Perhaps this would be a good starting point:
<div class="Right">
<div class="header-search">
<input type="text" class="searchbox" />
<input type="button" class="searchbutton" value="›" />
</div>
</div>
div.Container div.Right {
position: relative;
width: 50%;
float: right;
border: 1px dashed green;
height: 95px !important;
padding: auto 0 auto 200px;
}
div.header-search {
position: absolute;
right: 0;
top: 0;
overflow: auto;
display: inline;
text-align: right !important;
border: 3px dashed blue;
padding: 20px 0 auto 50px;
}
remove all styling from your div's as this is bad practice. Next, convert your two styles for .Right and .header-search like this:
div.Right {
border: 1px dashed green;
height:95px;
position: relative;
}
div.header-search {
border:1px dashed blue;
position: absolute;
top: 30px;
right: 0;
}
This should accomplish what you are attempting. There isn't a clean, easy way to center vertically, but since you have a fixed height on the outter .Right div and a fixed height on the search elements, it's best just to use a fixed top position on the inner .header-search.
You can see it in action on this jsfiddle:
http://jsfiddle.net/L4sgc/

Resources