I'm struggling placing my form elements where I like them to be.
I like my recurrence_interval input field below my select (recurrence) input field.
My two radio boxes for never and on. On top of each other and the input field for ends_on_date below the check box for "On".
My html is as below.
<div id="dialog" title="Create new appointment">
<form id="df">
<label class="align" for="title">Title</label>
<input type="text" name="title" id="title">
<label class="align" for="when">When</label>
<input type="text" name="when" id="when">
<input id="repeat" type="checkbox">
<label id="repeat_text" for="repeat">Repeat...</label>
<div id="repeat_properties">
<label class="align" for="recurrence">Repeats</label>
<select id="recurrence">
<option value="1">Daily</option>
<option value="7">Weekly</option>
<option value="repeat-x-days">Every x day</option>
</select>
<input id="recurrence_interval" type="text">
<label class="align" for="ends_never">Ends</label>
<input id="ends_never" name="endson" type="radio" title="Ends never" checked="checked">
<label for="ends_never" title="Ends never">Never</label>
<input id="ends_on" name="endson" type="radio" title="Ends never">
<label for="ends_never" title="Ends never">On</label>
<input class="align" id="ends_on_date" type="text">
</div>
</form>
</div>
My css is as below.
.align {
display: inline-block;
float: left;
clear: left;
width: 30%;
text-align: left;
}
input[type="text"], input[type="radio"], select {
display: inline-block;
float: left;
clear: right;
}
#repeat
{
display: inline-block;
float: left;
text-align: left;
clear: left;
}
#repeat_text
{
float: left;
}
Anyone got a clue about how I can archive the above?
Edit: As seen here, at least with chrome, the fields are clearly out of place.
change your HTML structure for radio, try using this.
<label for="ends_never" title="Ends never"><input id="ends_never" name="endson" type="radio" title="Ends never" checked="checked"> Never</label>
<label for="ends_never" title="Ends never"><input id="ends_on" name="endson" type="radio" title="Ends never"> On</label>
edited
try to add styling label { float : left; }
Related
I am trying to align my form contents so that each label falls on a separate line and the input content within the label falls in separate lines after the label element. Please help. I included an image link and my code in this question.
I would like my label to be displayed above the input elements, the input elements to have centered content (for example: radio type inputs to be aligned perfectly centered with their relative text description. If I have "male" as an option for a radio, I would like the input button itself to be aligned centered and even with the words "male").
html,
body {
height: 100vh;
width: 100vw;
margin: 0;
padding: 0;
display: block;
}
div {
display: block;
}
.form-group {
margin: 0 auto;
}
.container {
max-width: 600px;
margin: auto;
}
form {
height: 100%;
width: 100%;
display: block;
}
label {
padding: 0.25rem;
display: flex;
width: 100%;
}
input[type="radio"],
label {
align-items: center;
}
input {
width: 100%;
display: block;
}
<body>
<div class="container" style="text-align: center;">
<h1 id="title">Studentas Survey Form</h1>
<p id="description">Thank you for taking time to complete this survey</p>
</div>
<div class="container">
<form id="survey-form">
<div class="form-group">
<label id="name-label">Enter your name
<input type="text" id="name" placeholder="Enter your name" required></input>
</label>
<label id="email-label">Enter your Email
<input type="email" id="email" placeholder="Enter your email" required></input>
</label>
<label id="number-label">Enter your age
<input type="number" id="number" min="1" max="99" placeholder="Age" required></input>
</label>
<label>Favorite subject?
<select id="dropdown">
<option value="">Select an option</option>
<option value="1">History</option>
<option value="2">Math</option>
<option value="3">Science</option>
<option value="4">English</option>
</select>
<label>
<label>What is your gender?
<input type="radio" name="gender" required>Male</label>
<input type="radio" name="gender" required>Female</label>
</label>
<label>What do you like about school?
<input type="checkbox" value="lunch" required>Lunch Time</input>
<input type="checkbox" value="social" required>Social Interaction</input>
<input type="checkbox" value="work" required>Course Work</input>
<input type="checkbox" value="home" required>Going Home</input>
</label>
<label>What are your thoughts on this survey?
<textarea></textarea>
</label>
<input type="submit"></input>
</div>
</form>
</div>
</body>
Check this out!
.Your-choosen-label
{
display:flex;
justify-content:space-evenly;
align-items:center;
flex-direction:column;
}
So for my raid buttons, I want them to align to the right of my text, like other elements above, but I cant figure out how.
Here is the fiddle and code I have for my buttons.
<label>What kind of Ice Cream you like?</label>
<label><input type="radio" name="icecream" value="choco" id="radio"> Chocolate</label><br>
<label><input type="radio" name="icecream" value="vanil" id="radio">Vanilla</label><br>
<label><input type="radio" style="vertical-align: middle" name="icecream" value="rocky" id="radio">Rocky Road</label><br>
https://jsfiddle.net/russiandobby/gfj1nper/4/
I tried many ways but my radio buttons either end up under the text or messed up order like that.
Try using an id for each radio, like this:
<div>
<label for="chocolate">Chocolate</label>
<input type="radio" name="icecream" value="choco" id="chocolate">
</div>
*edited
<input type="radio" name="icecream" value="choco" id="chocolate">
<label for="chocolate">Chocolate</label>
<input type="radio" name="icecream" value="choco" id="vanila">
<label for="vanila">Vanila</label>
the name attribute should have same value rather than the id's having same value
You'll need to mess with the styling more to align everything exactly how you want it, but to get the radio inputs to the right of the text simply put the <input> element after the <label> element.
At the moment your <label> is wrapping the input. Place it wholly before the <input> element.
Additionally: for usability and accessibility, clicking the label should trigger your radio input. To enable this set a for="" attribute on each label that matches a unique id="" attribute for each input.
<label for="choco">Chocolate</label><input type="radio" name="icecream" value="choco" id="choco">
<label for="vanil">Vanilla</label><input type="radio" name="icecream" value="vanil" id="vanil">
<label for="rocky">Rocky Road</label><input type="radio" style="vertical-align: middle" name="icecream" value="rocky" id="rocky">
Try These Solutions
body{
background-color:#42f4e2;
}
#title{
text-align:center;
font-family: 'Lobster', cursive;
font-size: 50px;
}
#mainform{
background-color:#e8ecf2;
margin-top: 20px;
margin-right: 20px;
margin-bottom: 20px;
margin-left: 20px;
border-radius: 10px;
}
label{
display: inline-block;
width: 140px;
text-align: right;
margin-right: 40px;
margin-top: 20px;
}
#survey-form{
display: block;
margin-left: auto;
margin-right: auto;
width: 95%;
text-align:center;
}
select{
display: inline-block;
height:30px;
text-align: right;
margin-right: 40px;
margin-top: 20px;
}
.redio-wrap label{
display: inline-block;
margin-right: 10px;
width: auto;
}
.redio-wrap label:first-child{
width: 140px;
margin-right: 40px;
}
<h1 id="title">Survey Form</h1>
<div id="mainform">
<form action="/action_page.php" method="get" id="survey-form">
<label>*First name:</label> <input type="text" name="fname" placeholder="Enter your name"><br>
<label>*Email:</label> <input type="text" name="email" placeholder="Enter your Email"><br>
<label>*Age:</label> <input type="text" name="age" placeholder="Enter your Age"><br>
<!--For the Drop Down menu-->
<label>Describe your mood:</label>
<select>
<option value="" disabled selected>Select your option</option>
<option value="happy">Happy</option>
<option value="sad">Sad</option>
<option value="angry">Angry</option>
<option value="neutral">Neutral</option>
</select><br>
<!--For the Drop Down menu end-->
<!--Radio buttons start-->
<div class="redio-wrap">
<label>What kind of Ice Cream you like?</label>
<label><input type="radio" name="icecream" value="choco" id="radio"> Chocolate</label>
<label><input type="radio" name="icecream" value="vanil" id="radio">Vanilla</label>
<label><input type="radio" style="vertical-align: middle" name="icecream" value="rocky" id="radio">Rocky Road</label>
</div>
</form>
</div>
I had the same problem, and upon reviewing I found the following to solve the problem, which I applied to your ice cream variables:
First, in the HTML window, apply the following:
<div class="rowTab">
<div class="labels">
<label for="ice cream Type"> What kind of Ice Cream you like?</label>
<div/>
<div class="rightTab">
<ul style="list-style: none;">
<li class="radio">
<label>Chocolate<input name="radio-buttons"
value="1" type="radio" class="ice cream Type"></label></li>
<li class="radio">
<label>Vanilla<input name="radio-buttons"
value="2" type="radio" class="ice cream Type"></label></li>
<li class="radio">
<label>Rocky Road<input name="radio-buttons"
value="3" type="radio" class="ice cream Type"></label></li>
THEN, in the CSS window apply the following:
.ice cream type,
input[type="checkbox"] {
float: right;
margin-right:??px;
}
In this case, from the HTML window you are defining the class 'ice cream type' for each flavor, then in the CSS window you are styling it with 'float: right;' which should put the radio buttons to the RIGHT of each flavor's name..
i am beginner in css i am building a webpage in bootstrap . i want two labels Percentage and UpperLimit both to the same level i applied the inline class but unable to figure it out why there is level difference and how to correct it.
my html code is
<form class="form-horizontal">
<div class="control-group">
<label class="control-label">Promo Value</label>
<div class="controls">
<label class="radio inline" id="label1">
<input type="radio" name="optionsRadios1" id="optionsRadios4" value="option1" class="inline" checked>Percentage</label>
<label for="hello" class="inline" id="label2">Upper Limit
<input id="hello" type="text" class="inline" placeholder="Text input" disabled="true" />
</label>
<br />
<input type="radio" name="optionsRadios1" id="optionRadios6" value="option3">
<label class="radio inline" id="label3">Fixed Amount</label>
<input type="text" class="inline" placeholder="Amount Rs" disabled="true">
<hr class="hhhh"></hr>
</div>
</div>
</form>
and my main.css file is
.inline {
display:inline-block;
margin-right:20px;
}
.inline1 {
display:inline-block;
height: 50px;
vertical-align: middle;
margin-top: 2px;
}
and the screen shot is
as
as you can see the difference between label Upper Limit and Percentage is clearly visible how to resolve it help !!
The trick here is to over-ride some of the Bootstrap styles.
Here is one way of doing it. Modify your HTML slightly by keeping the labels and input fields separate (not nested). Use the "for" attribute to link the labels to the input fields.
<form class="form-horizontal">
<div class="control-group">
<label class="control-label">Promo Value</label>
<div class="controls">
<input type="radio" name="optionsRadios1" id="optionsRadios4" value="option1" checked>
<label class="radio inline" id="label1">Percentage</label>
<label for="hello" class="inline" id="label2">Upper Limit</label>
<input id="hello" class="inline" type="text" placeholder="Text input" disabled="true" />
<br />
<input type="radio" name="optionsRadios1" id="optionRadios6" value="option3">
<label class="radio inline" id="label3">Fixed Amount</label>
<input type="text" class="inline" placeholder="Amount Rs" disabled="true">
<hr class="hhhh"></hr>
</div>
</div>
</form>
I used the following CSS, making the selectors specific enough to override the Bootstrap styles.
.form-horizontal .control-group label.inline {
display: inline-block;
margin-right: 20px;
line-height: 30px;
vertical-align: baseline;
margin-top: 2px;
}
.form-horizontal .control-group input.inline {
vertical-align: baseline;
}
.form-horizontal .control-group .radio.inline {
padding-left: 10px;
}
.form-horizontal .control-group input[type="radio"] {
float: none;
display: inline-block;
vertical-align: baseline;
}
The gist of it is to make sure that the various inline elements are use vertical-align: baseline.
The styling is a bit complex, but it kind of works.
I did not try to place the .control-label element, but that should be easy enough.
The demo fiddle is: http://jsfiddle.net/audetwebdesign/PhqhS/
Essentially I'm trying to float, most of the list item elements horizontally with with the input underneath the label. Here is a template of what I'm trying to achieve.
I've included some of the code here:
<div>
<label for="headline">Headline: </label>
<input type="text" name="headline" value="Milestone" maxlength="50"size="55">
<br>
<div class="dates clearfix">
<label for="effect_date">Date of Effect:</label>
<input type="text" name="effect_date">
<label for="end_date">End Date (opt):</label>
<input type="text" name="end_date">
<label>Date Visible:</label>
<input type="radio" name="is_date_visible" value="2012">
<label for="is_date_visible_yes">Yes</label>
<input type="radio" name="is_date_visible">
<label for="is_date_visible_no">No</label>
<br>
<label>Administrative:</label>
<input type="radio" name="is_adminis" value="1">
<label for="is_admin_yes">Yes</label>
<input type="radio" name="is_adminis">
<label for="is_admin_no">No</label>
</div>
</div>
And the CSS:
.clearfix:before, .clearfix:after { content: ""; display: table; }
.clearfix:after { clear: both; }
.clearfix { *zoom: 1; }
div.dates {
}
.dates label {
display: block;
color: #2c93d5;
font-size: 15px;
margin-bottom: 5px;
}
.dates input {
display: block;
}
.dates label, .dates input {
float: left;
}
I've tried various things with the CSS all to no avail. Essentially I can't get the inputs to drop below the labels and I can't line them all up they usually come out staggered from the top.
I also have a fiddle link I've been working on:
http://jsfiddle.net/vjDEq/
Thanks for any help.
Here's something similar, without using floats:
http://jsfiddle.net/vjDEq/19/
HTML
<div>
<label for="headline">Headline: </label>
<input type="text" id="headline" name="headline" value="Milestone" maxlength="50"size="55">
</div>
<div class="dates">
<label for="effect_date">Date of Effect:
<input type="text" name="effect_date">
</label>
<label for="end_date">End Date (opt):
<input type="text" name="end_date">
</label>
<fieldset>
<legend>Date Visible:</legend>
<label for="is_date_visible_yes">
<input type="radio" name="is_date_visible" id="is_date_visible_yes" value="yes">
Yes
</label>
<label for="is_date_visible_no">
<input type="radio" name="is_date_visible" id="is_date_visible_no" value="no">
No
</label>
</fieldset>
<fieldset>
<legend>Administrative:</legend>
<label for="is_admin_yes">
<input type="radio" name="is_adminis" id="is_admin_yes" value="1">
Yes
</label>
<label for="is_admin_no">
<input type="radio" name="is_adminis" id="is_admin_no" value="0">
No
</label>
</fieldset>
</div>
CSS
#headline {
margin-bottom: 1em;
}
label {display: block;}
.dates label {
color: #2c93d5;
font-size: 15px;
margin-bottom: 5px;
}
.dates input {
display: block;
}
.dates fieldset input {
display: inline;
}
.dates label, .dates fieldset {
display: inline-block;
margin-right: 2em;
}
.dates fieldset label {
margin-right: 1em;
}
Instead of floats, the labels wrap the inputs and are set to inline-block. The radio buttons should be in a fieldset. Note that jsfiddle is adding normalize.css, which removes borders/margins/padding from the fieldset and legend. You have the option of floating the Administrative fieldset to the right if your layout demands it.
In this JSfiddle have I made a form without using tables.
The problem is that I can't get the submit button on the same line as "Type" and below the End Data field.
Does anyone know how to do that?
HTML
<div class="create-new">
<div id="create_result" style="display:none;">
</div>
<form id="create_form" name="create_form" action="" method="post">
<input name="anchor" id="anchor" value="create" type="hidden">
<label class="new" for="title">Title:</label>
<input class="new" type="text" name="title" id="title" />
<label class="new" for="owner">Owner:</label>
<input class="new" type="text" name="owner" id="owner" /><br class="new"/>
<label class="new" for="users">Users:</label>
<input class="new" type="text" name="users" id="users"/>
<label class="new" for="groups">Groups:</label>
<input class="new" type="text" name="groups" id="groups" /><br class="new"/>
<label class="new" for="begin_date">Begin Date:</label>
<input class="new" type="text" id="from" name="from"/>
<label class="new" for="end_date">End Date:</label>
<input class="new" type="text" id="to" name="to"/><br class="new"/>
<label class="new" for="type">Type:</label>
<input name="ctype" id="ctype" value="individuel" type="radio" /> Individuel <br/>
<input name="ctype" id="ctypee" value="course" type="radio" /> Course <br/>
<button class="n" type="submit">Create</button>
</form>
</div>
CSS
label.new, input.new, select.new, textarea.new { display: block; float: left; width: 150px; margin-bottom: 10px; }
label.new { width: 110px; text-align: right; padding-right: 10px; margin-top: 2px; }
textarea.new { height: 50px; }
br.new { clear: left; }
i nput.n { display: block; float: right; width: 150px; }
.create-new { display: inline-block; position: relative; left: 25%; }
I changed input.n to button.n and adjusted the styles to display:inline
button.n { display: inline; float: right; width: 150px; }
I also moved the button placement in your code to right under the label
<label class="new" for="type">Type:</label>
<button class="n" type="submit">Create</button>
<input name="ctype" id="ctype" value="individuel" type="radio" /> Individuel
http://jsfiddle.net/jasongennaro/CKC29/
One way to do it would be to put the items into a list (ul) then in your CSS set display: inline; for the two elements you would like to be on the same line.
You could try this:
Add the button.n selector to the first two label lines on top, so that it does the same as the labels so as the label with type.
button.n, label.new, input.new, select.new, textarea.new { display: block; float: left; width: 150px; margin-bottom: 10px; }
button.n, label.new { width: 110px; text-align: right; padding-right: 10px; margin-top: 2px; }
If the class name of n was a typo in your code above, just take the right classname, probably new instead of n.
The only way of doing it changing only the css is to set "display:inline" for the inputs that preceed your submit buttom.