Change search form button text to image - html

I can't seem to get my head around the following problem. So I procured a template of a search form which I then changed to fit my design requirements but I can't seem to be able to change the value=s bit to an image of a search box button. Please see http://jsfiddle.net/p9URB/. The code is as follows:
HTML
<form action="/search" method="get" id="search_form" class="clearfix voicetron" data-ds-protection="enabled">
<div id="search_holder">
<input type="text" id="search_field" name="q" value="" title="Enter search term" placeholder="Search" data-validators="required" data-speech-enabled="" data-search-engine="oracle" x-webkit-speech="x-webkit-speech" autocomplete="off">
<input type="text" id="search_suggest" value="" placeholder="" disabled="">
<input type="submit" value="y" data-submit-text="s" class="btn_search iconify" title="Search">
</div>
</form>
CSS
#search_form{
position:relative;
margin:10px 0;
float:right
}
#search_form #search_holder{
display:block
}
#search_form #search_holder input[type="text"]{
font-size:13px;
width:180px;
height:26px;
margin:0;
position:absolute;
right:0;
padding:0 32px 0 6px
}
#search_form #search_holder #search_field{
z-index:3;
border:1px solid #C9C9C9;
background:url("") #fff;
-webkit-border-radius:5px;
-moz-border-radius:5px;
-o-border-radius:5px;
-ms-border-radius:5px;
border-radius:5px;
text-shadow:0 0 1px #fff
}
#search_form #search_holder #search_field:focus,#search_form #search_holder #search_field:hover{
border-color:#acb1b4;
color:#123
}
#search_form #search_holder #search_field:-moz-placeholder{
color:#a6a7a8
}
#search_form #search_holder #search_field::-webkit-input-placeholder{
color:#a6a7a8
}
#search_form #search_holder #search_field:-moz-placeholder{
color:#a6a7a8
}
#search_form #search_holder #search_suggest{
z-index:2;
border:none;
background:#fff;
border:1px solid #fff;
-webkit-border-radius:5px;
-moz-border-radius:5px;
-o-border-radius:5px;
-ms-border-radius:5px;
border-radius:5px;
color:#9da2a8
}
#search_form #search_holder .overTxtLabel{
z-index:113
}
#search_form .active{
color:#fff;
background:#a6a7a8
}
#search_form .btn_search{
z-index:3;
position:absolute;
top:4px;
right:1px;
display:block;
color:#a6a7a8;
width:28px;
height:21px;
font-size:17px;
line-height:21px;
text-align:center;
font-weight:400;
background:0 0;
border:0;
border-left:1px dotted #a6a7a8
}
#search_form .btn-anchor{
background:0 0;
border:0;
border-bottom:1px solid #ccc;
color:#666;
margin:0 10px;
font-size:10px;
padding-bottom:2px;
font-weight:400
}
#search_form.voicetron [name="q"]{
padding-right:34px;
width:170px;
line-height:17px
}
#search_form.voicetron .btn_search{
color:#71767a
}

You can use an input type of image as your submit button:
<input type="image" src="/my/image/location.png" />
Instead of styling up a submit button. As far as I know, the input type of image replicates the submit behaviour of a submit button.

Add this to btn_search iconify class of css and specify an image.
background: url("your_url.png") no-repeat scroll 0 0 transparent;

You have set input value="s" so change it to value="" and add background image for that button
#search_form.voicetron .btn_search{
color:#71767a;
background-image:url('http://findicons.com/files/icons/1389/g5_system/16/toolbar_find.png');
background-repeat:no-repeat;
}
Js Fiddle

You can simply treat the button as a block element and remove the text with
text-indent:-9999px;
then set a background image.
You probably also want to add
cursor:pointer;
As it doesn't look like a button at the moment.

Related

Unable to add circle user avatar on login form

I'm a beginner in web development and I have made a Signup form for a webpage . What I feel like is trully missing from the form is a circular avatar icon on top of it like the picture below :
I have html and css code and I have loaded an avatar icon . However I do not know how to place it on the top middle of the form just like the image . I would appreciate your help and guidance with this task .
My code :
//the avatar appears inside the page not on top
.avatar{
height:500px;
border-radius:50%;
}
.form-area{
position:absolute;
top:50%;
left:50%;
transform:translate(-50%,-50%);
width:500px;
height:600px;
box-sizing:border-box;
background:rgb(0,0,0,0.5);
padding:40px;
}
h1{
margin:0;
padding:0 0 20px;
font-weight:bold;
color:#ffffff;
}
.form-area p {
margin:0;
padding:0;
font-weight:bold;
color:#ffffff;
}
.form-area input,select{
margin-bottom:20px;
width:100%;
}
.form area input[type=text], .form-area input[type="password"]
{
border:none;
border-bottom:1px solid #ccc;
background-color:transparent;
outline:none;
height:40px;
color:#ffffff;
display:16px;
}
.form-area select{
margin-top:20px;
padding:10px 0;
}
.signupbtn{
border:none;
height:40px;
outline:none;
color:#ffffff;
font-size:15px;
background-color:#4CAF50;
cursor:pointer;
border-radius:20px;
}
.cancelbtn{
border:none;
height:40px;
outline:none;
color:#ffffff;
font-size:15px;
background-color:tomato;
cursor:pointer;
border-radius:20px;
}
button:hover{
opacity:0.7;
}
<div class="form-area">
<form action="Start_page.html" class = "sign-form animate" onsubmit="return validateform()" method = "post">
//the avatar I want to display on the form
<div class="imgcontainer">
<img src="IMAGES/login.jpg" alt="Avatar" class="avatar">
</div>
<div class="container">
<h1>Sign Up</h1>
<p>Please fill in this form to create an account.</p>
<hr>
<label for="name" ><b><span>Name<span></b></label>
<input type="text" placeholder="Enter Name" name="onoma" id = "myname" required>
<label for="surname" ><b><span>Surname<span></b></label>
<input type="text" placeholder="Enter Surname" name="epith" id = "mysurname" required>
<label for="email" ><b><span>Email<span></b></label>
<input type="text" placeholder="Enter Email" name="email" id = "mailID" required>
<label for="psw"><b><span>Password</span></b></label>
<input type="password" placeholder="Enter Password" name="psw" id = "pass" required>
<p>By creating an account you agree to our Terms & Privacy.</p>
<div class="clearfix">
<button type="button" class="cancelbtn" onclick = "window.location.href='Start_page.html'">Cancel</button>
<button type="submit" class="signupbtn">Sign Up</button>
</div>
</div>
</form>
</div>
Thank you in advance . If you have any questions or need more information about my page tell me and I will update the post.
Add this to the image:
.imgcontainer img{
height: 100px; /* set a default height*/
margin-top: -75px; /* move image up fo 75px */
border: 1px solid black; /* define a border */
border-radius: 50%; /* make the image rounded, this works only with square images*/
}
and this to it's container:
.imgcontainer{
display: flex; /* change display */
justify-content:center;/* align to the center the image */
/* NOTE : there is a lot of other way to align the image to the center, you can use the one that you prefer*/
}
If this method does not do what you want in the way you want, another way is to use position: absolute, center it on center top, and than traslate it -50% top and -50% left

input loses its margin when opacity of sibling changes

<div id='mdnew'>
<div class=' gblue mdtitle'>NEW TAG</div>
<input id='inpnew' type='text' autocomplete='off' maxlength=25 placeholder='NEW TAG'>
<div class='gblue leftcancel'>CANCEL</div>
<div class='gblue rightok' id='newok'>OK</div>
<div class='clear'></div>
</div>
when input has focus (i.e. pointer is inside) and mouse is over cancel button - input loses its left margin !
complete code is here
Wrap your input with div and it will work.
* {
margin:0;
padding:0;
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
}
#mdnew {
position:fixed;
z-index:2;
width:300px;
left:calc(50% - 150px);
top:63px;
background: red;
border-radius:5px;
overflow:hidden;
}
#inpnew {
display:block;
width:calc(100% - 28px);
margin:14px auto;
line-height:21px;
outline:none;
border:1px solid #999;
border-radius:5px;
padding:0 7px;
}
.leftcancel {
float:left;
width:50%;
line-height:23px;
cursor:pointer;
text-align:center;
}
.rightok {
float:right;
width:50%;
line-height:23px;
cursor:pointer;
text-align:center;
}
.leftcancel:hover, .rightok:hover {
opacity:0.8;
}
.gblue {
background: -webkit-linear-gradient(to top, #003b61, #0099cc);
background: linear-gradient(to top, #003b61, #0099cc);
color:white;
letter-spacing:0.5px;
}
.mdtitle {
line-height:23px;
text-align:center;
letter-spacing:0.5px;
}
<div id="mdnew">
<div class=" gblue mdtitle">NEW TAG</div>
<div>
<input id="inpnew" type="text" autocomplete="off" maxlength="25" placeholder="NEW TAG" >
</div>
<div class="gblue leftcancel">CANCEL</div>
<div class="gblue rightok" id="newok">OK</div>
<div class="clear"></div>
</div>
Here is the Updated Fiddle..
Its because opacity of .leftcancel,rightok on hover, its effecting to the sibling
remove that part and test
.leftcancel:hover, .rightok:hover{
//opacity:0.8;
}
fiddle
Update :
To make it work with opacity, add position and z-index to .leftcancel and .rightok
The opacity you're setting on .leftcancel and .rightok is creating a new stacking context, and stacking contexts affect z-indexes. Since you didn't specify z-indexes manually, they're being auto assigned, and .leftcancel and .rightok has a higher value than #inpnew because it comes later in the markup.
Reference : W3C Color Module
If an element with opacity less than 1 is not positioned, implementations must paint the layer it creates, within its parent stacking context, at the same stacking order that would be used if it were a positioned element with ‘z-index: 0’ and ‘opacity: 1’.
*{
margin:0;
padding:0;
box-sizing:border-box;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
}
#mdnew{
position:fixed;
z-index:2;
width:300px;
left:calc(50% - 150px);
top:63px;
background: red;
border-radius:5px;
overflow:hidden;
}
#inpnew{
display:block;
width:calc(100% - 28px);
margin:14px auto;
line-height:21px;
outline:none;
border:1px solid #999;
border-radius:5px;
padding:0 7px;
}
.leftcancel{
position:relative;
z-index:5;
float:left;
width:50%;
line-height:23px;
cursor:pointer;
text-align:center;
}
.rightok{
position:relative;
z-index:5;
float:right;
width:50%;
line-height:23px;
cursor:pointer;
text-align:center;
}
.leftcancel:hover, .rightok:hover{
opacity:0.8;
}
.gblue{
background: -webkit-linear-gradient(to top, #003b61, #0099cc);
background: linear-gradient(to top, #003b61, #0099cc);
color:white;
letter-spacing:0.5px;
}
.mdtitle{
line-height:23px;
text-align:center;
letter-spacing:0.5px;
}
<div id='mdnew'>
<div class=' gblue mdtitle'>NEW TAG</div>
<input id='inpnew' type='text' autocomplete='off' maxlength=25 placeholder='NEW TAG'>
<div class='gblue leftcancel'>CANCEL</div>
<div class='gblue rightok' id='newok'>OK</div>
<div class='clear'></div>
</div>
Updated fiddle is : https://jsfiddle.net/5qperdzb/16/
If you're calculating input's width as 100% - 28px then it's safe to just use 14px for margin-left and margin-right:
#inpnew {
margin: 14px;
}

Media Queries acting funny in Chrome/Safari

I am working on a responsive website and I ran into a problem with the form. I have a outer container that hold the form and the submit button. When the user's browser reaches 524px or smaller the submit button will move below the outer container. Everything works fine in Firefox but when I'm using Safari/Chrome the submit button will not move back into the outer container.
I have an example of the problem here: yourl.co
Here is my HTML:
<div id="content">
<div id="formContent">
<form id="forms">
<input id="email" type="email" class="text" placeholder="You#example.com" name="user[email]"/>
<input id="submit" type="button" class="text" name="user[submit]" value="Notify Me!"/>
</form>
</div>
</div>
And here is my CSS:
#content{
width:100%;
max-width:573px;
height:auto;
margin:45px auto 0 auto;
}
#formContent{
width:99%;
height:56px;
margin:40px auto 0 auto;
background-color:#f6f5f5;
}
#forms{
border:none;
height:51px;
}
#forms #email{
width:75.1%;
height:51px;
border:none;
margin-top:2px;
background-color:#f6f5f5;
margin-left:6px;
}
#forms #email[type="email"]{
font-family:ubuntu-light;
font-weight:100;
font-size:1.875em;
color:#7baec6;
}
#forms #email[type="email"]:focus{
color:#498cab;
outline:none;
}
#forms #submit{
width:21.5%;
height:47px;
float:right;
margin-right:6px;
margin-top:5px;
border:1px solid #0e5779;
cursor:pointer;
}
#media only screen and (max-width: 524px){
#formContent{
width:95%;
max-width:524px;
margin:40px auto 73px auto;
}
#forms #email{
width:95%;
border:none;
margin-top:2px;
background-color:#f6f5f5;
margin-left:6px;
}
#forms #submit{
width:125px;
margin:12px auto 0 auto;
float:none;
display:block;
}
}
If you need anymore information I will be glad to provide it. Thanks for your help!
If you'll add css float: left; to #forms #email everything will be fine.
You can test it here: http://jsfiddle.net/witchfinderx/qwnXT/1/

Search text field and button height / position (CSS)

I have a problem with my search box. I'm trying to make the text field and button the same height, but I can't get it right in all browsers. Here is the code: http://codepen.io/anon/pen/ygCFz . This method works fine in Firefox, but not in Chrome.
So what would be the best method to have an equal height and position for both the text field and button?
Thanks!
//edit: because someone asked for the code for further reference, here it is:
HTML
<form id="search" action="" method="get">
<input type="text" name="search" class="sfield" value="search and go"/>
<input type="submit" value="Search" class="sbutton"/>
</form>
CSS
input.sfield{
background-color:#fff;
border-color:#cecece;
border-style:solid;
border-width:1px 0 1px 1px;
font-size:0.9em;
line-height:1em;
height:26px;
}
input.sbutton{
background-color:#d91515;
height:inherit;
border:none;
color:#fff;
position:relative;
left:-6px;
bottom:-1px;
height:28px;
}
Use padding instead height on input elements. Line-height should be exactly the same as font-size for Firefox. So if you want you font-size to 16px, put your line-height to 16px and add padding at top and bottom. For your submit button, use absolute positionning to be sure it will be at top:0 and bottom:0. Just add padding-left for submit button width equivalent on input and it's all done !
#search {
position:relative;
display:inline-block;
}
input.sfield{
background-color:#fff;
border-color:#cecece;
border-style:solid;
border-width:1px 0 1px 1px;
font-size:0.9em;
line-height:1;
padding:5px;
display:inline-block;
padding-right:50px;
}
input.sbutton{
background-color:#d91515;
border:none;
color:#fff;
position:absolute;
top:0px;right:0px;bottom:0px;
width:50px;
}
You can either set a definite height property for both elements or you can simply tell Sbutton to inherit the styles from Sfield.
<input type="submit" value="Search" class="sfield sbutton"/>
I also adding a bit of padding to make it even.
http://codepen.io/anon/pen/zBlwD
HTML:
<form id="search" action="" method="get">
<input type="text" name="search" class="sfield" value="search and go"/><input type="submit" value="Search" class="sbutton"/>
</form>
CSS:
input.sfield{
background-color:#fff;
border-color:#cecece;
border-style:solid;
border-width:1px 0 1px 1px;
font-size:0.9em;
line-height:0.9em;
height:26px;
margin: 0;
}
input.sbutton{
background-color:#d91515;
height:inherit;
border: 1px solid #d91515;
color:#fff;
position:relative;
margin: 0;
height:30px;
}
Well, I hope the solution isn't this simple, but you have height defined twice in your rule for the sbutton class:
input.sfield{
background-color:#fff;
border-color:#cecece;
border-style:solid;
border-width:1px 0 1px 1px;
font-size:0.9em;
line-height:1em;
height:26px;
}
input.sbutton{
background-color:#d91515;
height:inherit; //that's one
border:none;
color:#fff;
position:relative;
left:-6px;
bottom:-1px;
height:28px; //that's two
}
See what happens when you get rid of one. It should work. Also take a look at the line-height rule for your textbox. If the font size is different than the line height, that would explain why the sizes are different. Firefox and Chrome use different conversions from ems to pixels and vice versa.

How to put web form elements on a new line?

How to place "input" elements on new lines? In the above example all elements are placed sequentially, ie lable->input->lable->input, etc.
/* ----------- My Form ----------- */
.myform{
margin:0 auto;
padding:14px;
}
#stylized{
border-width:1px;
border-style:solid;
border-color:#b7ddf2;
background:#ebf4fb;
}
#stylized h1 {
font-size:14px;
font-weight:bold;
margin-bottom:8px;
border-width:1px;
border-style:solid;
border-color:#b7ddf2;
padding-bottom:10px;
}
#stylized label{
display:block;
font-size:11px;
font-weight:bold;
text-align:right;
float:left;
}
#stylized input{
float:left;
font-size:11px;
padding:4px 2px;
border:solid 1px #aacfe4;
width:70px;
margin:2px 0 20px 10px;
}
/* --------- End of Form --------- */
<div id="stylized" class="myform">
<form id="form" name="form" method="post" action="index.html">
<h1>Data</h1>
<label>Name: </label>
<input type="text" name="name" id="name"/>
<label>Email: </label>
<input type="text" name="email" id="email"/>
<label>Password: </label>
<input type="text" name="password" id="password"/>
</form>
</div>
#stylized input{
display: block;
font-size:11px;
padding:4px 2px;
border:solid 1px #aacfe4;
width:70px;
margin:2px 0 20px 10px;
}
This will put every input on a new line.
- Removed "float: left", added "display: block".
I put them under list tags and it worked without changing styles and using a break tag is obsolete
<ul>
<li><input type = "text" name = "selection" value = "text1" /> Text1</li>
<li><input type = "text" name = "selection" value = "text2" /> Text2</li>
</ul>
Have you tried anything as simple as
<label>Name: </label><br>
<input type="text" name="name" id="name"/>
<label>Email: </label><br>
<input type="text" name="email" id="email"/>
My guess is user1359163's anwswer will help, though you might care to know why: using float effectively removes the element out of the document's normal flow, a bit like changing the z-index, allowing the element to flow over div borders, labels, spans and... 'ignore' clear styles.
The element behaves as if it floats over the other elements, so in that respect, it stays clear of the left and right of all other elements that don't float.
I'm no CSS expert, but this way of looking at it has helped me a lot in solving issues with mangled layouts I've encountered when using the float, clear and z-index styles.
You prevent new lines when selecting a floating layout with enough room for all elements.
Try this:
Sample
http://jsfiddle.net/8yZff/
#stylized label{
font-size:11px;
font-weight:bold;
text-align:right;
}
#stylized input{
font-size:11px;
padding:4px 2px;
border:solid 1px #aacfe4;
width:70px;
margin:2px 0 20px 10px;
display: block;
}
Here is JsFiddle for that...
Edit :
#stylized label{
font-size:11px;
font-weight:bold;
text-align:right;
}
#stylized input{
display:block;
font-size:11px;
padding:4px 2px;
border:solid 1px #aacfe4;
width:70px;
margin:2px 0 20px 10px;
}​
For tabular data, such as an array of label/field pairs, use a table. You will find styling much easier, and nonstyled appearance much better.