How to set input text be shown inline with css? - html

I try to make inputs be displayed one after another in line using float: right.
[input][input][input]
But instead of it i see steps:
[input]
[input]
[input]
Do anyone has any suggestions? I use labels in form as following
here is my code:
כותרת נוספת
<label for="pa_passport">מספר ת.ז</label>
<input type="text" name="pa_passport" id="pa_passport" placeholder="מספר ת.ז" /><br />
<label for="pa_firstName">שם פרטי</label>
<input type="text" name="pa_firstName" id="pa_firstName" placeholder="שם פרטי" /><br />
<label for="pa_lastName">שם משפחה</label>
<input type="text" name="pa_lastName" id="pa_lastName" placeholder="שם משפחה" /><br />
<div style="clear:both"> </div>
<label for="pa_city">עיר מגורים</label>
<input type="text" name="pa_city" id="pa_city" placeholder="עיר מגורים" /><br />
<label for="pa_car">מספר רכב</label>
<input type="text" name="pa_car" id="pa_car" placeholder="מספר רכב" /><br />
<label for="pa_city">שנת ייצור</label>
<input type="text" name="pa_year" id="pa_year" placeholder="שנת ייצור" /><br />
<h4 class="faqlike bluecolh2">כותרת נוספת</h4>
<label for="pa_phone">טלפון</label>
<input type="text" name="pa_phone" id="pa_phone" placeholder="טלפון" /><br />
<label for="pa_phone"></label>
<select>
<option>054</option>
<option>052</option>
<option>053</option>
<option>050</option>
<option>08</option>
<option>09</option>
</select>
===UPDATE=====
Here is my scss:
.private_area {
label {
display:none;
}
input[type=text] {
float: right;
}
}

I think this is what you want right?
body { direction:rtl;}
H4 { clear:both; padding:20px 0;}
label { display:inline-block; width: 70px; margin:0 5px 0 0;}
.field { float:right;}
DEMO
let me know if you have any questions :) בהצלחה

I think the problem is the break statement after each input.

Related

Why are my HTML forms appearing differently in Sharepoint and jsfiddle?

I'm mocking up a Sharepoint Web Part in this fiddle and it currently looks like this (the second form has yet to be formatted/aligned, as you can see):
(even this, in addition to the ugly formatting on the second form, is not perfect, as the second form aligns a "row" below where I'd like it to be).
I'm using the exact same CSS and HTML on a Sharepoint Web Part, and it is considerably different:
I want the second form to the right, not below, the first form. The Sharepoint representation does not seem to restrict the form widths to allow this, though. Why the difference, and how can I make the Sharepoint Web Page more closely mimic the jsfiddle version?
Here is the code (again, exactly the same in both places):
CSS
.underline {
text-decoration: underline;
}
input[placeholder] {
font-size: 0.6em;
width: 500;
}
.firstblocklabel {
width: 160px;
display: inline-block;
margin: 2px;
}
.firstblockdatelabel {
width: 108px;
display: inline-block;
}
.firstblockinput {
width: 224px;
}
.dateinput {
width: 124px;
margin: 2px;
}
.timeinput {
width: 100px;
}
form {
display: inline-block;
vertical-align:top;
//float: left;
}
.borderedform {
border: 1px solid;
margin: 1em;
padding: 1em;
}
.reditalics {
color: red;
font-style: italic;
}
.wrappedlabel { width: 320px; display: block; }
HTML
<h2 class="underline">UCSC POST TRAVEL EXPENSE</h2>
<label>Form Filled Out:</label>
<input type="date" style="width=100px"></input>
<label>Access the Post Travel Guide for reimbursement validation</label>
<br/>
<br/>
<form>
<label class="firstblocklabel">Traveler's name:</label>
<input class="firstblockinput" type="text" id="travelername" title="Last Name, First Name, Middle Initial" />
<br/>
<label class="firstblocklabel">Traveler's E-mail:</label>
<input class="firstblockinput" type="email" id="traveleremail" />
<br/>
<label class="firstblocklabel">Traveler's Phone:</label>
<input class="firstblockinput" type="tel" id="travelerphone" />
<br/>
<label class="firstblocklabel">Traveler's Mail Stop:</label>
<input class="firstblockinput" type="text" id="travelermailstop" />
<br/>
<label class="firstblocklabel" id="travelerstreetorpoboxlabel">Traveler's Street or P.O.:</label>
<input class="firstblockinput" type="text" id="travelerstreetorpobox" />
<br/>
<label class="firstblocklabel">Traveler's Destinations:</label>
<input class="firstblockinput" type="text" id="travelersdestinations" />
<br/>
<label class="firstblocklabel">UC Business Purpose:</label>
<input class="firstblockinput" type="text" id="ucbusinesspurpose" />
<br/>
<label class="firstblockdatelabel">Departure Date:</label>
<input class="dateinput" type="date" id="travelersdeparturedate" />
<label>Time:</label>
<input class="timeinput" type="time" id="travelersdeparturetime" />
<br/>
<label class="firstblockdatelabel">Return Date:</label>
<input class="dateinput" type="date" id="travelersreturndate" />
<label>Time:</label>
<input class="timeinput" type="time" id="travelersreturntime" />
</form>
<form class="borderedform">
<label>Trip Number:</label>
<input type="text" id="tripnumber" title="If Applicable" />
<br/>
<label>Form prepared by:</label>
<input type="text" id="formpreparedby" />
<hr/>
<label>Dept / Division</label>
<input type="text" id="deptdivision" />
<br/>
<label>Email:</label>
<input type="email" id="email" />
<label>Ext:</label>
<input type="text" id="extension" />
<hr/>
<label class="reditalics">Required:</label>
<label>US Citizen - YES</label>
<input type="radio" id="uscitizenyes" value="YES" />
<label>NO</label>
<input type="radio" id="uscitizenno" value="NO" />
<br/>
<input type="radio" id="visitor" />Visitor
<label>Foreign Visa Type:</label>
<select title="Please select a visa type">
<option value="pleaseselect">Please Select</option>
. . .
</select>
<br/>
<input type="radio" id="ucstudent" />UC Student
<br/>
<input type="radio" id="ucemployee" />UC Employee
<label>UC Campus:</label>
<select title="Please select a campus">
<option value="pleaseselect">Please Select</option>
. . .
</select>
<br/>
<label class="wrappedlabel"><span style="color:red">Note: </span>If traveler chooses to include personal travel, record times/dates based only on the business portion of the trip. Provide explanation of personal travel.</label>
</form>
UPDATE
Adding Sully's CSS and HTML, the jsfiddle looks better, but the same additions to the Sharepoint Web Part don't change it at all there.
Maybe Sharepoint disallows multiple forms to be on the same "row"?
UPDATE 2
Unfortunately but not surprisingly, it looks different in Chrome (the other non-fiddle scream shot was IE):
Try making your forms float:left.
Bonus: for borderedform, use margin-left instead of just margin in order to remove that vertical space at the top.
CSS
.firstform { float: left; }
.borderedform {
float: left;
border: 1px solid;
margin-left: 1em;
padding: 1em;
}
To use that CSS, add class="firstform" to the first form.
http://jsfiddle.net/z8y6L303/

Labels and label styles not working on my form.

I am trying to style my form with labels and the label styles don't seem to work correctly.
Here is what my html looks like for the form:
<h1 class="allpages">Questions or Concerns about Compliance Issues?</h1>
<h3>We welcome all compliments and constructive criticism!</h3>
<form class="webform" action="http://hsc.unm.edu/scripts/cfmailform/cfmailer.cfm" method="post">
<!--Required hidden operators-->
<input name="recipient" type="hidden" value="bfloran#salud.unm.edu" />
<input name="subject" type="hidden" value="HSC Compliance Office Email Form" />
<input type="hidden" name="cc" value="mgwilson#salud.unm.edu" />
<input name="redirect" type="hidden" value="http://hsc.unm.edu/admin/compliance/ThankYOU.html" /> <!-- Field validation for the user -->
<!-- Our form in HTML -->
<label for "name">Your Name (optional):</label>
<br />
<input name="name" type="text" id="name" value="" /><br />
Your E-mail (Optional):<br />
<input name="mail" type="text" value="" />
<br /> comment:<br /> <textarea name="comment" value="" ></textarea><br /> <br /> <input type="submit" value="Send" /> <br /> <input type="reset" value="Reset" /></div>
My css for this part looks like this:
.allpages {text-align:center;color:#007a86;}
h3{text-align:center;}
.webform {background-color: #eeeeee;
width: 655px; border: solid;
border-color: #e9e9e9;margin-left: auto; margin-right: auto; padding: 15px 0px 15px 17px;}
.webform .label {display:inline-block; width:200px; vertical-align:top; text-align:right;}
label is not a class... it is a tag.
Working CSS for that piece:
.webform label { } /* see .label changed to label */
Also: Your elements were not laid out properly in HTML, some were not even labels.
Fixed fiddle: http://jsfiddle.net/digitalextremist/mt4jK/2/
Excerpt:
.webform label {
width:200px;
vertical-align:top;
text-align:right;
float: left
}
<label for="name">Your Name (optional):</label>
<input name="name" type="text" id="name" value="" />
You created a class selector to reference some tag with class=label

Why the input text and password fields are not line up?

First: you must see the following picture.
As you see, the red rectangle, the two fields does not line up, there is a little space in the start of the top field, while the next field does not.
Note: this problem occurs in all browsers.
HTML
<body>
<br /><br /><br /><br /><br />
<div id="loginForm">
<form action="login.php" method="post">
<label> Username: <input type="text" name="username" id="username" /></label><br />
<label> Password: <input type="password" name="password" id="password" /></label><br /><br />
<input type="submit" name="sbmtLogin" value="login" />
</form>
</div>
</body>
CSS
body {margin:0; padding:0;}
div#loginForm {width:270px; max-width:270px; margin:0 auto; padding:10px; text-align:center; background-color:#8de3fd;}
div#loginForm input {margin:3px; padding:5px; color:#5b5b5b; width:150px; border:1px solid #9a9a9a;}
div#loginForm input[type=submit] {width:70px;}
How can I fix that problem ?
Why the input text and password fields are not line up?
Username and Password are different length words
How can I fix that problem ?
Use a monospace font
Wrap the words in an element that you set to display: inline-block; width: ??? where ??? is a fixed value.
That element could be the labels.
<label for="username"> Username:</label> <input type="text" name="username" id="username" /></label><br />
<label for="password"> Password:</label> <input type="password" name="password" id="password" /></label>
label {
display: inline-block;
width: 7em; /* adjust to taste */
}
Keep in mind that you will get different fonts on different systems, so give yourself some leeway with the width of the elements if you take the second approach.
"Username:" is slightly wider than "Password:"
That is why they are not aligned.
You want to do something like putting the fields in a table or defined width divs.
It's because the text of Username: is a few pixels longer than Password: ?
You need to close the label tags, so the text is actually in the label (setting the for attribute will also make the inputs selectable by clicking the label)
<body>
<br /><br /><br /><br /><br />
<div id="loginForm">
<form action="login.php" method="post">
<label for="username"> Username:</label> <input type="text" name="username" id="username" /></label><br />
<label for="password"> Password:</label> <input type="password" name="password" id="password" /></label> <br /><br />
<input type="submit" name="sbmtLogin" value="login" />
</form>
</div>
</body>
Then put a common width on the labels with css
div#loginForm form label {
display: inline-block;
width: 200px; // whatever looks best
}
Not all characters of the font has the same width for all fonts. In your case Username is slightly larger than the Password, therefore the alignment issue.
To fix the issue you need to put the labels in a fixed with box
HTML - wrapped each input element in a div
<body>
<br /><br /><br /><br /><br />
<div id="loginForm">
<form action="login.php" method="post">
<div><label>Username:</label><input type="text" name="username" id="username" /></div>
<div><label>Password:</label><input type="password" name="password" id="password" /></div>
<div><input type="submit" name="sbmtLogin" value="login" /></div>
</form>
</div>
</body>
CSS - set width of label and set display to inline-block
body {margin:0; padding:0;}
div#loginForm {width:270px; max-width:270px; margin:0 auto; padding:10px; text-align:center; background-color:#8de3fd;}
div#loginForm input {margin:3px; padding:5px; color:#5b5b5b; width:150px; border:1px solid #9a9a9a;}
div#loginForm input[type=submit] {width:70px;}
#loginForm label { width: 100px; display: inline-block; }

Why won't my two column form line up correctly?

I'm learning some css and want to make a two column form, without any table tags and such.
This is what i have got (code from CSS Cookbook 3ed edition).
JSfiddle HERE...
HTML code:
<div class="container">
<form id="regform" name="regform" method="post" action="/regform.php">
<div id="register">
<h4>Register</h4>
<label for="fmlogin">Login</label>
<input type="text" name="fmlogin" id="fmlogin" />
<label for="fmemail">Email Address</label>
<input type="text" name="fmemail" id="fmemail" />
<label for="fmemail2">Confirm Address</label>
<input type="text" name="fmemail2" id="fmemail2" />
<label for="fmpswd">Password</label>
<input type="password" name="fmpswd" id="fmpswd" />
<label for="fmpswd2">Confirm Password</label>
<input type="password" name="fmpswd2" id="fmpswd2" />
</div>
<div id="contactinfo">
<h4>Contact Information</h4>
<label for="fmfname">First Name</label>
<input type="text" name="fmfname" id="fmfname" />
<label for="fmlname">Last Name</label>
<input type="text" name="fmlname" id="fmlname" />
<label for="fmaddy1">Address 1</label>
<input type="text" name="fmaddy1" id="fmaddy1" />
<label for="fmaddy2">Address 2</label>
<input type="text" name="fmaddy2" id="fmaddy2" />
<label for="fmcity">City</label>
<input type="text" name="fmcity" id="fmcity" />
<label for="fmstate">State or Province</label>
<input type="text" name="fmstate" id="fmstate" />
<label for="fmzip">Zip</label>
<input type="text" name="fmzip" id="fmzip" size="5" />
<label for="fmcountry">Country</label>
<input type="text" name="fmcountry" id="fmcountry" />
<input type="submit" name="submit" value="send" class="submit" />
</div>
</form>
</div>
CSS code:
label {
margin-top: .33em;
display: block;
}
input {
display: block;
width: 250px;
}
#register {
float: left;
}
#contactinfo {
padding-left: 275px;
}
Because you float one div and not the other.
With a few simple CSS changes it'll work (as long as the h4 does not span multiple lines):
#register {
float: left;
width: 275px;
}
#contactinfo {
float: left;
}
See the updated fiddle.
Here's how I'd debug (except I'd use Firebug or another Inspect/devtools): http://jsfiddle.net/PhilippeVay/yuxTA/2/
As stated by #Arjan in his answer, this is due to floating and its effects.
Uncomment the last CSS declaration for a solution that won't modify layout. Also add margin-top to both columns or padding-top if you want a vertical margin back...
Another option is to remove the margins from the h4 (although, as said in other answers, floating [or similar] both columns makes more sense).
h4 {margin: 0;}
You have to float all the div in your containter
#register {
float: left;
}
#contactinfo {
float:left;
margin-left:30px; /*increase or decrease if you like*/
}

CSS spacing issue in Firefox Select Field

I am having a spacing issue with CSS when using Firefox. This works fine in Chrome. When I have a form with fields and labels the line after a select field is getting extra space in front of it.
You can see the problem in the image here: http://i51.tinypic.com/35b8gmf.png . Where is the space in front of the text 'test2' coming from?
Here is the code:
<style>
label {
float:left;
width:70px;
}
input, select {
width:130px;
}
</style>
<label for="l1">test1</label>
<select id="l1" name="test1"><option>a</option></select>
<br>
<label for="l2">test2</label>
<input id="l2" type="text" size="30" name="test2">
<br>
<label for="l3">test3</label>
<input id="l3" type="text" size="30" name="test3">
<style>
label {
float:left;
width:70px;
}
input, select {
width:130px;
}
</style>
<label for="l1">test1</label>
<select id="l1" name="test1"><option>a</option></select>
<br style="clear:both;">
<label for="l2">test2</label>
<input id="l2" type="text" size="30" name="test2">
<br style="clear:both;">
<label for="l3">test3</label>
<input id="l3" type="text" size="30" name="test3">
<div id="tests">asd</div>