Form with panels using css - css

I want to achieve a form using css which have different panels for different groups of input fields.
Similar to this.
![alt text][1]
I know this is a desktop client. But is there any way to achieve such a layout with fieldsets css ?

You can use float:
<form>
<div id="col1">
<fieldset id="fldst1"></fieldset>
<fieldset id="fldst2"></fieldset>
<fieldset id="fldst3"></fieldset>
</div>
<div id="col2">
<fieldset id="fldst4"></fieldset>
<fieldset id="fldst5"></fieldset>
</div>
<div id="col3">
<fieldset id="fldst6"></fieldset>
<fieldset id="fldst7"></fieldset>
<fieldset id="fldst8"></fieldset>
</div>
<div style="clear:both;" />
</form>
In your CSS:
#col1, #col2, #col3 {
float: left;
width: 300px;
}
Then you place the different form elements in your fieldsets.

I'm not quite sure what part of the layout exactly is the problem. You obviously know about fieldset and you layout them exactly the same way you would layout any other HTML element (such as div).
I'm guessing it the columns. You have two possibilities here. A) Either put a number of fieldsets into a div with the width (100% / number of columns) and float those divs, or B) if you only need to support modern browsers use CSS 3 column properties and the browser will calculate the number of fieldsets per column for you automatically:
A)
#columns .column {
float: left;
width: 33%;
}
<div id="columns">
<div class="column">
<fieldset>...</fieldset>
<fieldset>...</fieldset>
<fieldset>...</fieldset>
</div>
<div class="column">
<fieldset>...</fieldset>
<fieldset>...</fieldset>
<fieldset>...</fieldset>
</div>
<div class="column">
<fieldset>...</fieldset>
<fieldset>...</fieldset>
<fieldset>...</fieldset>
</div>
</div>
B)
#columns {
column-count: 3
/* Just covering all bases here. Not sure which browsers actually support this */
-webkit-column-count: 3
-moz-column-count: 3
-o-column-count: 3
-ms-column-count: 3
}
<div id="columns">
<fieldset>...</fieldset>
<fieldset>...</fieldset>
<fieldset>...</fieldset>
<fieldset>...</fieldset>
<fieldset>...</fieldset>
<fieldset>...</fieldset>
<fieldset>...</fieldset>
<fieldset>...</fieldset>
<fieldset>...</fieldset>
</div>

CSS:
<style type="text/css">
fieldset {
width: 33%;
float: left;
}
</style>
HTML:
<fieldset>
<legend>Anschrift</legend>
<label for="nachname">Nachname:</label>
<input id="nachname" name="nachname" type="text">
</fieldset>
<fieldset>
<legend>Firmenanschrift</legend>
<label for="firma">Firma:</label>
<input id="firma" name="firma" type="text">
</fieldset>
<fieldset>
<legend>Einkommen</legend>
<label for="jaresgehalt">Jaresgehalt:</label>
<input id="jaresgehalt" name="jaresgehalt" type="text">
</fieldset>

Related

Don't apply CSS for specific parents class

I have html like
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label class="control-label">Values</label>
<div class="form-inline">
#Html.Kendo().NumericTextBoxFor(m => m.Min).Decimals(2);
#Html.Kendo().NumericTextBoxFor(m => m.Max).Decimals(2);
</div>
</div>
</div>
</div>
Kendo's numeric text box has .k-numerictextbox class. and i have CSS
.form-group .k-numerictextbox {
width: 100% !important;
}
with this settings currently CSS is getting applied to NumericTextBox.
I dont want CSS to apply on NumericTextBox if its under form-inline class
For this specific html structure (there is always one element between .k-numerictextbox and .form-group which either is or not .form-inline) then
.form-group *:not(.form-inline) .k-numerictextbox {
width:100%;
}
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label class="control-label">Values</label>
<div class="form-inline">
<input class="k-numerictextbox" />
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label class="control-label">Values</label>
<div class="form-not-inline">
<input class="k-numerictextbox" />
</div>
</div>
</div>
</div>
(keep in mind that it is a fragile rule, because if there is yet another container of the .k-numerictextbox inside the .form-group it will not work)
I would remove using !important since it's probably not needed. Add another rule with more specificity (including the .form-inline would be a good way to do this:
.form-group .k-numerictextbox {
width: 100%;
}
.form-group .form-inline .k-numerictextbox {
width: auto;
}

How do I fit an image to a bootstrap div="col-md"?

Im trying to copy the following picture with bootstrap
Here's the link if you want to see it https://slack.com/create#teamname
The image does fit the entire page, even though you scroll down , it won't show any extra picture, while mine does have.
My attempt is
<body>
<div class="container">
<div id="Page1">
<h1>Full Name</h1>
<div class="row">
<div class="col-md-5">
<h1></h1>
<form>
<input type="text" placeholder="Enter your Full Name" class="form-control">
Show page 2
</form>
</div>
<div class="col-md-7">
<img src="/img/space.jpg">
</div>
</div>
</div>
</div>
</body>
I add some custom css to the image
img {
width:100%;
height:730px;
}
and I got the following the result
How do i match the first picture in code?
I'm not a frontend guy , if anyone could help me would be really helpful.
Here's the JSFIDDLE --> https://jsfiddle.net/3soreoac/
http://codepen.io/anon/pen/wKQQxb
<div class="left col-md-6"></div>
<div class="right col-md-6"><img class="full" src="https://slack.global.ssl.fastly.net/66f9/img/signup/step1-illi#2x.png"></div>
.rightfull {
width: 100vh;
height: 100vh;
}
.left {
background-color: blue;
}
.right {
background-color: green;
}
This may help
HTML
<div class="container">
<div id="Page1">
<div class="row">
<div class="col-md-5 col-xs-5 leftpanel">
<h1>Full Name</h1>
<form>
<input type="text" placeholder="Enter your Full Name" class="form-control"> Show page 2
</form>
</div>
<div class="col-md-7 col-xs-7">
<img src="https://metrouk2.files.wordpress.com/2014/01/459405755-e1389347715754.jpg">
</div>
</div>
</div>
</div>
CSS
img{
width:100%;
height:732px;
}
.leftpanel{
background-color:grey;
height:732px;
}
Fiddle:here

Input field should take the remaining width

I am trying to build a form to add new users to some kind of entity. The idea is to have user avatars in a line and on the end of the line there is a input-field with a typeahead to insert new users.
I tried this some years ago and ended up using javascript as I was not able to do this in plain css (2).
The big question: is this somehow possible in css3?
Basic idea of code:
<div class="availableWidth">
<div class="list">
<ul>
<li><div class="avatar">...</div></li>
...
</ul>
</div>
<div class="form">
<div class="typeaheadField">
<input ...>
</div>
<button>+</button>
</div>
</div>
CSS:
.list ul li {
list-style-type:none;
display:inline-block;
}
button {
width:50px;
}
Basic Idea is that the box .availableWidth has some width (100%) the box .list grows in width (when new li items are added) as the box .form should shrink in width. Right to the input is a some pixels wide button. The input should take the remaining space.
Is that possible in css3 or will I need Javascript?
You can use flexbox, or you can use display table attributes in CSS. Take a look:
.container {
display: table;
width: 100%;
position:relative;
}
.avatar {
width: 50px;
height: 50px;
display: table-cell;
}
.input {
height: 50px;
display:table-cell;
vertical-align: middle;
}
.input input {
width: 100%;
box-sizing: border-box;
padding: 5px;
}
<div class="container">
<div class="avatar">
<img src="http://dummyimage.com/50x50/000/fff&text=Avatar"/>
</div>
<div class="avatar">
<img src="http://dummyimage.com/50x50/000/fff&text=Avatar"/>
</div>
<div class="avatar">
<img src="http://dummyimage.com/50x50/000/fff&text=Avatar"/>
</div>
<div class="input">
<input type="text"/>
</div>
</div>
<div class="container">
<div class="avatar">
<img src="http://dummyimage.com/50x50/000/fff&text=Avatar"/>
</div>
<div class="avatar">
<img src="http://dummyimage.com/50x50/000/fff&text=Avatar"/>
</div>
<div class="avatar">
<img src="http://dummyimage.com/50x50/000/fff&text=Avatar"/>
</div>
<div class="avatar">
<img src="http://dummyimage.com/50x50/000/fff&text=Avatar"/>
</div>
<div class="avatar">
<img src="http://dummyimage.com/50x50/000/fff&text=Avatar"/>
</div>
<div class="input">
<input type="text"/>
</div>
</div>
You can add all the avatars that you want at left side and the input rearrange automatically.
You want to make input 100% width relative to some container from avatars to button. You can get it by using table, flexboxes or formatting contexts and floats.
Here is last one http://jsfiddle.net/53f0yzeL/
Notice overflow:hidden rule for .avatars-wrapper, it make container to fit exactly between floated elements and .avatars side so you can make input 100% wide.

How to avoid overlapping when window is resized

I have 3 divs in total. One is a container for the other left and right divs. There will be so many containers. Everything is okay now, but when the window is resized the CSS should avoid overlapping the divs. Instead, it should wrap to the next line. Please provide me your suggestion. Below is my code.
Css Code
.divmain
{
width: 100%;
padding: 15px;
height: auto;
}
.divmain .divleft
{
float: left;
width: 16%;
}
.divmain .divright
{
float: left;
width: 84%;
}
View Code
<div style="width: 100%;">
<div class="divmain">
<div class="divleft">
<label class="label">Date</label>
</div>
<div class="divright">
<input type="text"/>
</div>
</div>
<div class="divmain">
<div class="divleft">
<label class="label">Status</label><span class="mand">*</span>
</div>
<div class="divright">
<label class="label">Pending</label>
</div>
</div>
<div class="divmain">
<div class="divleft">
<label class="label">Reference No</label>
</div>
<div class="divright">
<input type="text"/>
</div>
</div>
</div>
Demo

Using CSS for a multiple-column form

any suggestions on the best way to do a form like that? http://i.imgur.com/vT7tC.png
I'm using tables + input with width: 100%, I know it's probably not the best way
(also, for some reason the input width: 100% gets bigger than [td] or [div] (the red border on this image is from a [div][input ...][/div])
thanks
You can float the left label/inputs to the left and the right label/input to the right.
You will need to specify a width otherwise you will end up with a large gap between your columns and your middle column will not line up with your large right input.
This is how I would code that form:
HTML
<div class="content">
<div class="row">
<div class="lrow">
<label>aaa aaa</label>
<input type="text" class="large">
</div>
<div class="rrow">
<label>bbb</label>
<input type="text" class="small">
</div>
</div>
<div class="row">
<div class="lrow">
<label>ccc</label>
<input type="text" class="small">
</div>
<div class="rrow">
<label>ddd ddd</label>
<input type="text" class="large">
</div>
</div>
<div class="row">
<div class="lrow">
<label>eee</label>
<input type="text" class="small">
</div>
<div class="rrow">
<label>fff fff</label>
<input type="text" class="small">
</div>
<div class="crow">
<label>ggg</label>
<input type="text" class="small">
</div>
</div>
</div>
CSS
.content {width:542px;}
.row {overflow:hidden;margin:5px 0;}
.row label {float:left;text-align:right;width:60px;margin-right:5px;}
.row input {float:left;}
.lrow {float:left;}
.rrow {float:right}
.large {width:300px;}
.small {width:100px;}
don't waste your time by making columns by hand.
just use Blueprint CSS Framework. it's really nice and easy to use and does the job in a way you want.
the most important of all, you do not need to care about browser compatibility anymore.

Resources