Using CSS3 I am trying to display search box with glass image. I am doing it basically by placing a image on text box and setting its left-margin. My code is here:
<body>
<form id="header-search">
<input type="text" class="searchbox" /><input type="submit" class="button" value="" />
</form>
</body>
#header-search{overflow:auto;}
#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:1px solid #8e8e8e;
background-color:white;
height:16px;
padding:4px;
padding-left:28px;
padding-right:10px;
color:#4a4a4a;
float:left;
}
#header-search input.button{
border:0px dashed red;
padding:0;
margin:0 0 0 -185px;
width:24px;
height:24px;
background:transparent url(../images/SearchImage.png) center center no-repeat;
float:left;
}
UPDATE
I am not using em rather px
I have tried different css reset.
please see image for details difference.
I have done this code in new css/ html file where there is no other line of code.
Using position:absolute seems to be a more reliable approach for this kind of thing.
HTML
<form id="header-search">
<div class='relative'>
<input type="text" class="searchbox" /><input type="submit" class="button" value="" />
</div>
</form>
CSS
.relative {
position:relative;
}
.relative .button {
position:absolute;
left: 20px;
z-index:1;
}
You may want to make this css more specific to this search input rather than all .button's etc
Its because you are not specifying a width of your search input box.
If you do that, you method will work.
Else, of course, the better way is to use position:absolute to position your button.
This will ensure the layout across all browsers.
If you want to place image for search input box , you can try this http://jsfiddle.net/HmKZQ/1/
If you need the button for click then you can try this
http://jsfiddle.net/HmKZQ/3/
Related
Here are my buttons:
<body>
<form name="form1">
<span id="buttons">
<input type="button" name="button1" value="6"/>
<input type="button" name="button2" value="4"/>
<input type="button" name="button3" value="2"/>
</span>
</form>>
</body>
I cant for the life of me get them to be styled in css, I just dont know their identifier?
currently I'm using
<style>
#buttons {
"css style is here"
}
and that looks REALLY BAD
another method I tried was
<style>
input[type="button"] {
"css style is here"
}
which is exactly what I wanted, BUT absolute positioning made them all bunch up in the exact same space and I found no way to separate them.
I need either a way to clasify them and style them seperatly OR to space them when using the second method
"sidenote" Here's the css styling I used that caused them to bunch up:
<style>
input[type="button"] {
background:linear-gradient(to bottom, #44c767 5%, #05aaf7 100%);
display:inline-block;
border-radius:6px;
border:0px solid #83c41a;
cursor:pointer;
color:#ffffff;
font-family:Arial;
font-size:17px;
padding:16px 31px;
text-decoration:none;
text-shadow:0px 1px 0px #2f6627;
position:absolute;
left: 45%;
top: 30%;
}
</style>
I would like to have the tag "Member Login" on the border line in my code but I have no idea how to pull it off, I basically want something like this
Where you'd have "Select Pizza Size", I want to be able to display my text wrapped with a border, but I don't know how to.
My Code:
login.php
<html>
<head>
<title>Hospital Login</title>
<link href="login.css" rel="stylesheet" type="text/css">
</head>
<body>
<fieldset class="formDisplay">
<form name="form1" method="post" action="process_login.php">
<legend><strong>Member Login </strong></legend></br>
<strong>Username</strong></br></br> <input name="myusername" type="text" id="myusername">
</br></br>
<strong>Password</strong></br></br><input name="mypassword" type="password" id="mypassword">
</br></br>
<input type="submit" name="Submit" value="Login">
</form>
<?php
echo $message;
?>
</fieldset>
</body>
</html>
login.css
.formDisplay{
position:relative;
top: 15%;
left: 30%;
border: 5px groove threedface;
padding: 50px;
border-radius:20px;
width:400px;
height:250px;
text-align: center;
}
.formDisplay legend {
display: block;
word-wrap: initial;
}
Thanks in advance for your help
You need to wrap your form elements in a fieldset and make "Member Login" the legend.
See a basic example here:
http://www.w3schools.com/tags/tag_fieldset.asp
For more in-depth reading, visit:fieldset element # MDN
Update (based on revision to question)
The problem in your code is you have the fieldset outside the form element. Try this instead:
<form name="form1" method="post" action="process_login.php">
<fieldset class="formDisplay">
<legend><strong>Member Login </strong></legend></br>
...
...
...
</fieldset>
</form>
Try this:
#selection{
height:300px;
width:400px;
border:1px solid #666;
}
h3{
width:180px;
margin-top:-10px;
margin-left:10px;
background:#EEE;
padding-left:10px;
font-size:14px;
color:#000;
}
#spacer{
height:100px;
}
See the example here:
https://jsfiddle.net/aqx3kLqm/1/
Just to let you know, this is not a water proof solution, because you need to adjust the with of your text in the CSS, if the text is of a different lenth.
Hi i want to make a customized input text box like this image:
I search many articles but found nothing to do this so please help me
This is not a new answer. But some modification to answer of #alvaro-menéndez to make it more compact and generic.
div {
position:relative;
display:inline-block;
margin:50px;
}
input[type="text"] {
width:300px;
padding:10px;
outline:0;
border:0;
background-color: #eee;
}
.preinput {
position:absolute;
z-index:-1;
display:block;
bottom:-1px;
left:-1px;
border-bottom:1px solid #999;
border-right:1px solid #999;
border-left:1px solid #999;
width:100%;
height:20px;
}
<div>
<span class="preinput"></span>
<input type="text" placeholder="Search" />
</div>
You could use this little and simple jquery to add an element after your input:
$(".input").after("<span></span>");
and then you just have to style it like in this FIDDLE
Edited: updated fiddle to put the element UNDER the input and move it slightly bottom and left so it will be visible even if input has a background-color
You can just use a css background image on your input. Use a placeholder attribute for you "search".
HTML
<input type="search" placeholder="Search" />
CSS
input[type="search"]{
background:url(your_image_path) left bottom no-repeat;
}
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.
I have a input box for users to enter search terms in. I have a input button beside the search box. for some reason the button is rendering below the search box.
I want the button to be right beside the input box.
My html:
<div id="searchbox">
<form method="post" action="/search/test">
<div class="searchinput">
<input type="text" id="searchbox" value="" /></div>
<div class="searchbutton">
<input type="submit" id="searchboxbutton" value="Go" /></div>
</form>
</div>
CSS:
#header #searchbox
{
float:left;
width:400px;
padding:5px 0px 0px 0px;
}
#header #searchbox #searchinput
{
display:inline;
float:left;
}
#header #searchbox #searchbox
{
display:inline;
float:left;
}
#header #searchbox #searchbutton
{
display:inline;
float:left;
}
Simplify, simplify, simplify.
HTML
<form method="post" action="/search/test">
<input type="text" id="searchbox" value="" />
<input type="submit" id="searchboxbutton" value="Go" />
</form>
CSS
input {display: inline}
Your <input type="text" id="searchbox" value="" /> is matching this style (width: 400px) as well:
#header #searchbox
{
float:left;
width:400px;
padding:5px 0px 0px 0px;
}
IDs must be unique - change it or the containing element and write your styles accordingly.
http://validator.w3.org/docs/errors.html
141: ID X already defined
An "id" is a unique identifier. Each time this attribute is used in a
document it must have a different
value. If you are using this attribute
as a hook for style sheets it may be
more appropriate to use classes (which
group elements) than id (which are
used to identify exactly one element).
Just add this CSS to your CSS style sheet:
.searchinput{
display:inline-block
}
It will add your content in one row.
You have an id based selector in CSS (#searchinput) but you are using classes in markup (<div class="searchinput">). Change either of the ones and it should work.
Third, you don't need the display:inline. Just float: left will do. Also, floated elements are required to have a width. So set a width.
Probably because your #searchbox width is 400px and your input tag and button tag is more than 400 px.
Try making the #searchbox width to 600px and see what happens.
Change your css from
#header #searchbox
{
float:left;
width:400px;
padding:5px 0px 0px 0px;
}
#header #searchbox #searchinput
{
display:inline;
float:left;
}
#header #searchbox #searchbox
{
display:inline;
float:left;
}
#header #searchbox #searchbutton
{
display:inline;
float:left;
}
to
#header
{
float:left;
width:400px;
padding:5px 0px 0px 0px;
}
#searchinput, #searchbox, #searchbutton, #searchboxbutton
{
display:inline;
float:left;
}