HTML:
<div>Due date:<input type="text" name="dueDate" size="30" value="{{ticket.fields.interval.lastExecution|e}}" required disabled="disabled"></input></div>
<div>Created by:<input type="text" name="createdBy" size="30" value="{{ticket.fields.personCreated|e}}" required disabled="disabled"></input></div>
CSS:
.open-tickets-view input {
border: 0px solid #474a52;
border-radius: 0px;
max-width: 200px;
RESULT:
If I try to float right with inline-block display:
CSS:
.open-tickets-view input {
border: 0px solid #474a52;
border-radius: 0px;
max-width: 200px;
display: inline-block;
float: right;
RESULT:
I have tried several different combinations among display: flex and use justify-content: space-between but the text always breaks a new line.
With input elements it's a good thing to use <label>. Cause it's a label for the input. Default browser behavior with labels is that if you click on the label the mouse will focus the input. Read more about it here
Using float:
div.myDiv {
width: 300px;
border: solid 2px red;
}
div.myDiv:after {
/* clear floats is a good thing */
content: '';
display: block;
clear: both;
}
div.myDiv input {
float: right;
border:solid 2px green;
}
div.myDiv label {
border:solid 2px green;
}
<div class="myDiv">
<label for="uname">Choose a username: </label>
<input type="text" id="uname" name="name">
</div>
using positioning:
div.myDiv {
position: relative;
width: 300px;
border: solid 2px red;
}
div.myDiv input {
border:solid 2px green;
position: absolute;
right: 0;
}
div.myDiv label {
border:solid 2px green;
}
<div class="myDiv">
<label for="uname">Choose a username: </label>
<input type="text" id="uname" name="name">
</div>
You can use margin-left:auto on a child element of display:flex with flex-direction:row like below.
.container, .container > div {
display: flex;
flex-direction: row;
white-space:nowrap;
}
.container .right {
margin-left: auto;
}
<div class='container'>
<div>
<span>Due date:</span>
<input type="text" name="dueDate" size="30" value="{{ticket.fields.interval.lastExecution|e}}" required disabled="disabled" />
</div>
<div class='right'>
<span>Created by:</span><input type="text" name="createdBy" size="30" value="{{ticket.fields.personCreated|e}}" required disabled="disabled" />
</div>
</div>
Or maybe:
.container,
.container>div {
display: flex;
}
.container {
flex-direction: column;
}
.container>div {
flex-direction: row;
padding:1em;
}
.container .right {
margin-left: auto;
}
<div class='container'>
<div>
<span>Due date:</span>
<input class='right' type="text" name="dueDate" size="30" value="{{ticket.fields.interval.lastExecution|e}}" required disabled="disabled" />
</div>
<div>
<span>Created by:</span><input class='right' type="text" name="createdBy" size="30" value="{{ticket.fields.personCreated|e}}" required disabled="disabled" />
</div>
</div>
Related
I am currently trying to create a basic form using HTML & CSS. In it there are 4 fields: amount of men, amount of women, amount of kids and amount of beer per adult.
I want the first three inputs to be on one side, and the fourth to have its own space on the right. I have not been able to achieve this effect. The beer field should be centered horizontally to the right, and beneath it, the input box.
Maybe I should be using a table for this but alas, I am very new to CSS and am honestly a bit clueless.
body {
display: flex;
align-items: center;
justify-content: center;
}
#app {
border: 1px dotted black;
padding: 1.5em;
width: 30em;
}
#left-div {
display: inline-block;
padding: 0.5em;
border: 1px dotted black;
}
#left-div input {
width: 2em;
margin: 0.5em;
}
#left-div label {
margin: 0.5em 0em 0.5em 0em;
display: inline-block;
}
/* Chopp */
#div-chopp {
display: inline-flex;
border: 1px dotted black;
padding: 0.5em;
}
#div-chopp label {
display: block;
}
#div-chopp input {
width: 2em;
}
<div id="app">
<form action="POST">
<div id="left-div">
<label for="men">Men</label>
<input type="number" value="0" name="men">
<br>
<label for="women">Women</label>
<input type="number" value="0" name="women">
<br>
<label for="kids">Kids</label>
<input type="number" value="0" name="kids">
</div>
<div id="div-chopp">
<label for="beer">Litros de Beer por Adulto</label>
<input type="number" value="0" name="beer">
</div>
</form>
</div>
Here's a start. You could use more custom classes instead of the descendant selectors. Avoid using IDs, though, so your CSS is reusable.
body {
display: flex;
align-items: center;
justify-content: center;
}
.wrapper {
display: flex;
border: 1px dotted black;
padding: 1.5em;
width: 30em;
}
.wrapper>div {
display: flex;
flex-direction: column;
padding: 0.5em;
border: 1px dotted black;
}
.wrapper>div>div {
display: flex;
justify-content: space-between;
}
.wrapper>div:last-child>div {
justify-content: center;
}
.wrapper input {
width: 2em;
margin-left: .5em;
}
<div id="app">
<form action="POST">
<div class="wrapper">
<div>
<div>
<label for="men">Men</label>
<input type="number" value="0" name="men">
</div>
<div>
<label for="women">Women</label>
<input type="number" value="0" name="women">
</div>
<div>
<label for="kids">Kids</label>
<input type="number" value="0" name="kids">
</div>
</div>
<div>
<div>
<label for="beer">Litros de Beer por Adulto</label>
</div>
<div>
<input type="number" value="0" name="beer">
</div>
</div>
</div>
</form>
</div>
I want my form layout to look like the picture below:
This is what I currently have:
label {
display: inline-block;
border: 1px solid red;
}
input {
display: inline-block;
width: 28%;
margin-top: 1.5em;
margin-left: 2em;
border: 1px solid greenyellow;
}
<label for="First_Name"> First Name: </label>
<input type="text" id="First_Name">
<label for="Last_Name"> Last Name: </label>
<input type="text" id="Last_Name">
This is my output:
There are many ways to achieve this. Here is one possibility:
wrap each pair of label and input in a div (or similar)
use flexbox to get them to stack vertically
Everything else seems to be just a matter of inspecting the reference regarding the used colors and sizes, which you can do by using your Browser's Inspector (or looking at the source code). Alternatively, bring the provided image into an image editing program and check the colors there.
Here is a rough approximation based on the approach outlined above:
body {
background-color: #f6f7f5;
}
fieldset {
display: flex; /* use flexbox for content */
justify-content: center; /* center items horizontally */
border: none; /* remove default fieldset border */
}
.input {
flex-grow: 1; /* take up free space within parent */
flex-basis: 50%; /* width (before growing/shrinking) */
display: flex; /* use flexbox for content */
flex-direction: column; /* arrange content vertically */
margin: 1rem;
}
label {
padding: 0.5rem 0;
font-family: sans-serif;
font-size: 11pt;
color: #5b5b60;
}
input {
padding: 0.5rem;
color: #9d9d9d;
background: #fff;
border: 1px solid #ccc;
border-radius: 2px;
box-shadow:inset 0 1px 1px #eee;
}
.required label::after {
content: "*";
}
.required input {
border: 1px solid #a94442;
}
<fieldset>
<div class="input required">
<label for="First_Name">First Name:</label>
<input type="text" id="First_Name">
</div>
<div class="input">
<label for="Last_Name">Last Name:</label>
<input type="text" id="Last_Name">
<div>
</fieldset>
Try this code
label {
display: block;
}
input {
display: block;
width: 100%;
border: 1px solid greenyellow;
padding: 4px
}
.overflow {
width: 100%;
overflow: hidden
}
.pull-left {
width: calc(50% - 20px);
float: left;
margin: 10px
}
<div class="overflow">
<div class="pull-left">
<label for="First_Name"> First Name: </label>
<input type="text" id="First_Name">
</div>
<div class="pull-left">
<label for="Last_Name"> Last Name: </label>
<input type="text" id="Last_Name">
</div>
</div>
I have this form. I would like that until 768px width the form is inline, and afterwords the form should be vertical.
I am a little bit in doubt, if I have to set up a breakpoint, or bootstrap has a function that does that? As it is now, the form keeps being inline.
Does anybody knows how I can do that?
HTML
<div class="sign-up">
<p class="sub-header">#Helpers.GetText(CurrentPage, "signupHeaderText", CurrentPage.Parent)</p>
<form id="signupForm">
<div class="form-group">
<label class="sr-only" for="name">#Helpers.GetText(CurrentPage, "signupNameFieldText", CurrentPage.Parent)</label>
<input type="text" class="form-control" placeholder="#Helpers.GetText(CurrentPage, "signupNameFieldText", CurrentPage.Parent)" id="name" name="name" required />
</div>
<div class="form-group">
<label class="sr-only" for="email">#Helpers.GetText(CurrentPage, "signupEmailFieldText", CurrentPage.Parent)</label>
<input type="email" class="form-control" id="email" name="email" placeholder="#Helpers.GetText(CurrentPage, "signupEmailFieldText", CurrentPage.Parent)" required/>
</div>
<input type="text" id="Channel" name="Channel" style="display: none;" />
<input type="text" id="Campaign" name="Campaign" style="display: none;" />
<button type="submit" class="btn btn-default active">#Helpers.GetText(CurrentPage, "signupCtaButtonText", CurrentPage.Parent)</button>
</form>
</div>
SCSS:
.sign-up {
padding: $grid-gutter-width;
margin-bottom: $grid-gutter-width;
border-radius: 5px;
background-color: $white3;
.form-control {
box-shadow: none;
border-color: $white4;
}
.error {
border: 1px red solid;
}
label {
&#name,
&#email {
&-error {
display: none !important;
}
}
}
.btn {
margin: 0;
padding-top: 10px;
padding-bottom: 10px;
border: none;
width: 100%;
}
}
.signup-wide {
padding-top:15px;
form {
display: flex;
justify-content: space-between;
.form-group {
width: 33%;
height: 40px;
max-width: 200px;
input {
height: 100%;
}
}
.btn {
padding-top: 10px;
padding-bottom: 10px;
height: 40px;
width: 33%;
}
}
}
Bootsrap has system class for this, use <form class="form-inline">
Here is my HTML:
<form action="#" class="six columns push_two contact-form">
<label>
<span>Name</span>
<input type="text" name="name" />
</label>
<label>
<span>Email</span>
<input type="email" name="email" />
</label>
<label>
<span>Phone number</span>
<input type="text" name="phone" />
</label>
<label>
<span>Message</span>
<textarea name="message"></textarea>
</label>
<input type="submit" name="submit" value="Send" />
</form>
And CSS:
label{
display: table;
width: 100%;
border-bottom: solid $grey_dark 1px;
}
span{
display: table-cell;
font-weight: 700;
font-size: 20px;
}
input, textarea{
display: table-cell;
width: 100%;
}
In result I get something like the screenshot bellow. I have marked the spans with red border. They wider than I want. I did not set any width, margin or padding to them. But still they are wider. Can you give me a solution to this so that the spans become the size of the text width.
I want something like bellow:
You need to specify a table row, for table cells to behave. Try this:
form {display: table;}
label{
display: table-row;
width: 100%;
border-bottom: solid $grey_dark 1px;
}
Updated answer:
label{
display: block;
width: 100%;
border-bottom: solid #333 1px;
padding: 10px;
}
span{
display: inline-block;
padding-right: 15px;
font-weight: 700;
font-size: 20px;
}
input, textarea{
}
Instead of the display as table for span you need to use table-row.
label{
display: table-row;
width: 100%;
border-bottom: solid $grey_dark 1px;
}
I've got this HTML form:
<form method="post" action="#" class="cf">
<div class="left">
<label for="first-name">First Name</label>
<input type="text" name="first-name" placeholder="First Name" id="first-name" required />
<label for="last-name">Middle Name</label>
<input type="text" name="middle-name" placeholder="Middle Name" id="middle-name" />
<label for="last-name">Last Name</label>
<input type="text" name="last-name" placeholder="Last Name" id="last-name" required />
</div>
<div class="right">
<label for="details">Details</label>
<textarea name="details" placeholder="Details" id="details" required></textarea>
</div>
<input type="submit" name="submit" value="Submit Form" />
</form>
And this is my CSS:
/* Clearfix */
.cf:before,.cf:after { content: " "; display: table; }
.cf:after { clear: both; }
form > * {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.left {
background: rgba(255, 0, 0, .2);
}
.right {
background: rgba(0, 255, 0, .2);
}
form {
background: #ccc;
}
input[type="text"],
textarea {
width: 100%;
border: none;
}
input[type="text"] {
margin-bottom: 10px;
}
label {
display: inline-block;
margin-bottom: 5px;
}
#media only screen and (min-width: 600px) {
form {
background: rgba(0, 0, 255, .3);
}
.left {
float: left;
width: 50%;
}
.right {
float: right;
width: 50%;
}
input[type="submit"] {
clear: both;
}
}
Fiddle
http://jsfiddle.net/gRRmh/
Basically it's three text input fields, one textarea and one submit button (aka input type submit). When the breakpoint is reached, the form flows into a two column layout. That's the part that is working.
The part that is not working is the height of the textarea. I want it to be the same height as the three input fields on the left.
Setting it to height: 100%; does not work for two reasons:
The height of the label needs to be taken into account. Sure I could just give it a height in percentages and subtract that value from the textarea's height (10% / 90%) ...
...but for this to work, one parent elements needs a fixed height, so I need to give the form e.g. a height of 200px. The problem with that is I actually need to match the height of the left column by hand which isn't really a good solution.
So what I am actually looking for is something like the following, just without nudging pixels by hand:
(also with fiddle if you want, but please note: Its a bit messy. http://jsfiddle.net/mnBEh/1/)
How to solve this problem?
It is only posible by giving manually height to textarea.So give height to textarea on media queries.
Try this. It uses CSS tables, but I think it gets the result you're looking for, by setting the textarea to be 100% height, and then minusing the height of it's label. But for some reason, the height is only calculating correctly in Chrome, even though the other browsers supposedly support it.
http://jsfiddle.net/73cyorL1/
CSS:
.table {
display: table;
width: 100%;
}
.row {
display:table-row;
width: 100%;
}
.left {
background: red;
}
.right {
background: blue;
}
label {
display: block;
padding: 10px;
font-family: arial;
font-style: italic;
font-size: 0.75em;
line-height: 1em;
}
form {
background: grey;
}
input[type="text"], textarea {
width: 100%;
border: none;
background: #ccc;
font-family: arial;
padding: 10px;
box-sizing: border-box;
display: block;
}
input[type="text"]:focus, textarea:focus {
outline: 0;
background: #ddd;
}
input[type="submit"] {
display: block;
margin: 10px;
padding: 10px;
cursor: pointer;
}
#media only screen and (min-width: 600px) {
.left {
width: 50%;
height: 100%;
display: table-cell
}
.right {
width: 50%;
height: 100%;
display: table-cell;
overflow: hidden;
}
textarea {
height: calc(100% - 0.75em);
/* 100% fill height, minus height of details label */
}
}
HTML:
<form method="post" action="#" class="table">
<div class="row">
<div class="left">
<label for="first-name">First Name</label>
<input type="text" name="first-name" placeholder="First Name" id="first-name" required="required" />
<label for="last-name">Middle Name</label>
<input type="text" name="middle-name" placeholder="Middle Name" id="middle-name" />
<label for="last-name">Last Name</label>
<input type="text" name="last-name" placeholder="Last Name" id="last-name" required="required" class="last" />
</div>
<div class="right">
<label for="details">Details</label>
<textarea name="details" placeholder="Details" id="details" required></textarea>
</div>
</div>
<input type="submit" name="submit" value="Submit Form" />
</form>
Set "box-sizing: border-box;" and it will works