Chrome float: right image not aligning - google-chrome

I have this search button that is really giving me a hard time. I am trying to get it to line up properly with the search input area and when I finally got it to work in Firefox, it decided to get all weird in Chrome. Its like something is pushing the button down when viewed in Chrome.
Here is my HTML:
<div id="searchCon">
<form role="search" method="get" id="searchform" class="searchform" action="http://somesite.com/">
<div>
<label class="screen-reader-text" for="s">Search Our Site:</label>
<input type="text" value="" name="s" id="s">
<input type="image" value="Search" src="button.png" id="searchsubmit" style="opacity: 1; float: right;">
</div>
</form>
</div>
Here is my CSS:
#searchCon {
float: right;
display: inline-block;
height:37px;
padding: 0px 10px 10px 280px;
color:#2a2a2a;
}
I have been reading tons of forums, articles, etc and cannot get this little button to work properly in Chrome.
Please help me out!

Try this:
HTML:
<div id="searchCon">
<form role="search" method="get" id="searchform" class="searchform" action="http://somesite.com/">
<div style="float:left">
<label class="screen-reader-text" for="s">Search Our Site:</label>
<input type="text" value="" name="s" id="s" />
</div>
<div style="float:right;padding-top:2px">
<input type="image" value="Search" src="button.png" id="searchsubmit" style="opacity: 1; " />
</div>
</form>
</div>
CSS:
#searchCon {
float: right;
display: inline-block;
height:37px;
padding: 0px 10px 10px 0px;
color:#2a2a2a;
}

Related

close up spaces in a bootstrap form

I have a bootstrap form with the following css code in it. I have tried to close up the blank spaces in the form by adding margin:0 attribute but still the spaces between the element is there.
css form code
<div class="row-fluid">
<form style="width: 90%; height: 100%; margin-top:1px;" method="post"novalidate="novalidate" class="form well">
<div class="row-fluid">
<div>
<label for="complaints">Message *</label>
<textarea style="width:100%;" name="complaints" rows="3" required></textarea>
</div>
</div>
<div class="form-actions">
<input style="width:100%; background-color:#da291c;" class="btn btn-primary" name="commit" type="submit" value="Send">
</div>
</form>
</div>
this is the picture of the above form
My challenge is to close the gaps on the areas pointed with arrows.
I am using this version of bootstrap
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.1.1/css/bootstrap-combined.min.css">
You can remove the margin-bottom that bootstrap adds to the class .control-group
.row-fluid div.control-group, div.form-actions {
margin-bottom: 0px;
}
div.my-form{
padding-bottom: 0px;
margin-top:0px;
padding-top:0px;
}
.control-group input,.control-group textarea{
margin-bottom: 0px;
}
form.form{
padding-bottom: 0;
padding-top:0;
}
UPDATED jsfiddle with your code
You can use this code:
input[type=text], .txtarea{
margin-bottom: 10px;
}
In bootstrap already they keep on the margin property always. we can overwrite that to solve your problem.
you need to add one class like this:
.splclass{
margin:0 !important;
padding:0 !important;
}
Add additionally in the form inline style like this:
<form style="width: 90%; height: 100%; margin-top:1px; padding-top:5px;" method="post"novalidate="novalidate" class="form well ">
i think it will helpful
Well if you don't want any space in between, you definitely don't want any margin. Move the CSS to it's own file:
.send {
width:100%;
background-color:#da291c;
}
.message {
width:100%;
}
.form {
width: 90%;
height: 100%;
margin: 0;
}
and html:
<div class="row-fluid">
<form class="form" method="post" novalidate="novalidate" class="form well">
<div class="row-fluid">
<div class="control-group span12">
<label for="name">Name *</label>
<input ng-model="name" name="name" type="text" class="input-block-level" required>
</div>
</div>
<div class="row-fluid">
<div class="control-group span12">
<label for="email">Email *</label>
<input name="email" placeholder="" type="email" class="input-block-level" ng-model="email"ng-change="id=email" required>
</div>
</div>
<div class="row-fluid">
<div class="control-group span12">
<label for="complaints">Message *</label>
<textarea class="message" name="complaints" rows="3" required></textarea>
</div>
</div>
<div class="form-actions">
<input class="btn btn-primary send" name="commit" type="submit" value="Send">
</div>
</form>
</div>
and you can see the fiddle here: https://jsfiddle.net/6j98311j/

stop DIVs moving eachother

I have 2 divs that I want to position close together, however they keep moving eachother. They are both under the main div.
HTML:
<div id="header">
<div id="title">Social</div>
</div>
<div id="main">
<div id='notif'><strong>Incorrect details.</strong>
</div>
<div id="signin">
<form name="signinform" action="authenticate.php" method="post" onsubmit="return validate(this)" id="signinform">
<p>
<input placeholder="Username / Email" class="input" type="text" name="user" id="user" maxlength="50">
</p>
<p>
<input placeholder="Password" class="input" type="password" name="password" id="password" maxlength="50">
</p>
<p>
<input type="checkbox" name="remember" id="remember" value="checked">
<label for="remember">Remember me</label>
</p>
<p>
<input class="button" type="submit" value="Sign in">
</p>
</form>
</div>
</div>
The CSS is as follows:
Main body which both divs comes under:
#main {
padding-top: 50px;
}
Form div:
#signin {
padding-top: 5px;
padding-bottom: 5px;
width: 400px;
margin: auto;
margin-top: 150px;
}
Error div:
#notif {
padding-top: 5px;
padding-bottom: 5px;
width: 400px;
height: 20px;
margin: auto;
margin-top: 140px;
}
I know that perhaps it has something to do with the position attribute..
Here is an image of what it looks like now, as you can see, I want both of the center objects to be close together without pushing each other away from the vertical center.
remove the margin-top from the #signin div - as this is what is putting pixels between the #notif div and the #signin div.
#main {
padding-top: 50px;
}
#signin {
padding-top: 5px;
padding-bottom: 5px;
width: 400px;
margin: auto;
}
#notif {
padding-top: 5px;
padding-bottom: 5px;
width: 400px;
height: 20px;
margin: auto;
margin-top: 140px;
}
<div id="header">
<div id="title">Social</div>
</div>
<div id="main">
<div id='notif'><strong>Incorrect details.</strong>
</div>
<div id="signin">
<form name="signinform" action="authenticate.php" method="post" onsubmit="return validate(this)" id="signinform">
<p>
<input placeholder="Username / Email" class="input" type="text" name="user" id="user" maxlength="50">
</p>
<p>
<input placeholder="Password" class="input" type="password" name="password" id="password" maxlength="50">
</p>
<p>
<input type="checkbox" name="remember" id="remember" value="checked">
<label for="remember">Remember me</label>
</p>
<p>
<input class="button" type="submit" value="Sign in">
</p>
</form>
</div>
</div>
Debugging
In this sort of situation, your page inspector is going to be your best friend.
In chrome, for example, when the page inspector is open, hovering an element will show you the margins of the element, as well as any padding being given to it.

Fix header position when scrolling

i want to fix the header so it will be there even if i scrolled down
i tried to use position:fixed
<header style="margin-bottom: 1cm; position: fixed; ">
<div style="float:left;" align="left">Instagram User Explorer</div>
<div align="center">
<form name="contact" id="contact" method="get">
Search : <input type="text" name="keyword" id="keyword"/>
<input type="button" value="search!" name="submit" id="submit"/>
</form>
</div>
</header>
but the textfield and button wnt down i dont know why
and what i want is to be in the same line
<header style="margin-bottom: 1cm;">
<div style="float:left;" align="left">Instagram User Explorer</div>
<div align="center">
<form name="contact" id="contact" method="get">
Search : <input type="text" name="keyword" id="keyword"/>
<input type="button" value="search!" name="submit" id="submit"/>
</form>
</div>
</header>
like this :
how to do it ?
Fiddle is here
you need to do a little more work with css to get that effect, the background is just added for visibility in the fiddle. your body needs a margin that can clear the fixed header as well, as seen in .body class below
.header {
height: 50px;
position:fixed;
width: 100%;
background: #ddd;
top: 0;
}
.body {
margin-top: 70px;
}
<header style="margin-bottom: 1cm;">
<div style="float:left;">Instagram User Explorer</div>
<div style="float:right;">
<form name="contact" id="contact" method="get">
Search : <input type="text" name="keyword" id="keyword"/>
<input type="button" value="search!" name="submit" id="submit"/>
</form>
</div>
</header>

How do I get rid of the big margin between my labels and the input fields?

Below is my code, first of all:
How do I get rid of the big margin to the right that occurs between the labels and the input fields? I tried setting the margin-right to -150px which made it smaller but that just seems like an idiotic solution..
How can I remove the need to write <br /> to make them hop down a line automatically? I was told never to use <br />, it also seems messy.
HTML:
<div id="groupmepopup" class="popup">
<h4>Fill in your information so that you can be added.</h4>
<form action="" method="POST">
<label>In-game username:</label>
<input name="username" type="text"></input><br />
<label>Email:</label>
<input name="email" type="text"></input><br />
<label>Game:</label>
<input name="game" type="text"></input><br />
<input name="mySubmit" type="submit" value="Submit"></input>
</form>
</div>
CSS:
label {
display: block;
float: left;
width: 120px;
margin-right: 5px;
text-align: right;
}
You can try something like this
<div id="groupmepopup" class="popup">
<h4>Fill in your information so that you can be added.</h4>
<form action="" method="POST">
<p>
<label>In-game username:</label>
<input name="username" type="text"></input>
</p>
<p>
<label>Email:</label>
<input name="email" type="text"></input>
</p>
<p>
<label>Game:</label>
<input name="game" type="text"></input>
</p>
<p></p>
<input name="mySubmit" type="submit" value="Submit"></input>
</form>
</div>
and then the css
p label {
display: block;
float: left;
width: 120px;
margin-right: 5px;
}
p input{
float:right;
}
p{
clear:both;
}
form{
width:20em;
}
http://jsfiddle.net/V92PT/1/
But the fields part on table
like this
<div id="groupmepopup" class="popup">
<h4>Fill in your information so that you can be added.</h4>
<form action="" method="POST">
<table><tr><td><label>In-game username:</label></td>
<td> <input name="username" type="text"></input></td ></tr>
<tr><td> <label>Email:</label></td>
<td> <input name="email" type="text"></input></td></tr>
<tr><td> <label>Game:</label></td>
<td>
<input name="game" type="text"></input>
</td></tr>
</table>
<input name="mySubmit" type="submit" value="Submit"></input>
</form>
</div>
or add another <br/> after <label>In-game username:</label>
or use <p></P> for each row

How to centre input text box HTML?

I have a form and I want to centre the text boxes and label to the middle. How can I do this? (I would have thought aligning the left and right to auto would do it but it doesn't work). This is my code:
<body>
<div id="formWrapper">
</center>
<form method ="post" action="addMember.php">
<label for="name">Username:</label>
<input name="name"/>
<label for="password">Password:</label>
<input name="password"/>
<label for="email">Email:</label>
<input name="email"/>
<p>
<fieldset>
<input class="btn" name="submit" type="Submit" value="Register"/>
<input class="btn" name="reset" type="reset" value="Clear Form">
</fieldset>
</form>
</div>
</body>
The style:
#formWrapper{
width:550px;
padding: 2em 0 2em 0;
border:solid 5px #F1F1F1;
margin-top: 100px;
margin-right: auto;
margin-bottom: 0;
margin-left: auto;
background-color: #AFC8DE;
}
If you apply text-align: center to the form it will place the fields in the center.
Semantics are important here, so take a look at an accessible approach to forms. http://www.alistapart.com/articles/prettyaccessibleforms
take a look at this: http://jsfiddle.net/7auS8/
add align="center" to your form
div id="formWrapper">
<form method ="post" action="addMember.php" align="center">
<label for="name" >Username:</label>
<input name="name"/>
<p>
<label for="password">Password:</label>
<input name="password"/>
<p>
<label for="email">Email:</label>
<input name="email"/>
<p>
<fieldset>
<input class="btn" name="submit" type="Submit" value="Register"/>
<input class="btn" name="reset" type="reset" value="Clear Form">
</fieldset>
</form>
</div>
border: 1px solid gray;
border-radius:5px;
color: #393939;
height: 30px;
padding: 0px 6px 0 6px;
width: 186px;
I took this code and tried out adarshr answer and it does center the form. Chris is also right the semantics are very important here because after seeing it I feel like this might not be exactly what you were looking for. Another point I wanted to add to this to someone reading this who is probably a beginner is that when you add text-align: center; it needs to go in the css file and end with a ;