Display check boxes in a fieldset into three columns - css

I have a fieldset with check boxes organized with ul, li. I have three lists (all part the same fieldset). I want to display them into three columns, each ul (list) is a column from left to right.
Do I have to wrap each ul in a DIV?... I need help.
Here's what it looks like on my site right now... MaddenUltimateZone.com
<fieldset class="position">
<legend>Position:</legend>
<ul>
<li>Offense</li>
<li>
<input type="checkbox" id="qb" value="QB" />
<label class="position" for="qb">QB</label>
</li>
<li>
<input type="checkbox" id="hb" value="HB" />
<label class="position" for="hb">HB</label>
</li>
<li>
<input type="checkbox" id="fb" value="FB" />
<label class="position" for="fb">FB</label>
</li>
<li>
<input type="checkbox" id="wr" value="WR" />
<label class="position" for="wr">WR</label>
</li>
<li>
<input type="checkbox" id="te" value="TE" />
<label class="position" for="te">TE</label>
</li>
<li>
<input type="checkbox" id="lt" value="LT" />
<label class="position" for="lt">LT</label>
</li>
<li>
<input type="checkbox" id="lg" value="LG" />
<label class="position" for="lg">LG</label>
</li>
<li>
<input type="checkbox" id="c" value="C" />
<label class="position" for="c">C</label>
</li>
<li>
<input type="checkbox" id="rg" value="RG" />
<label class="position" for="rg">RG</label>
</li>
<li>
<input type="checkbox" id="rt" value="RT" />
<label class="position" for="rt">RT</label>
</li>
</ul>
<ul>
<li>Defense</li>
<li>
<input type="checkbox" id="le" value="LE" />
<label class="position" for="le">LE</label>
</li>
<li>
<input type="checkbox" id="re" value="RE" />
<label class="position" for="re">RE</label>
</li>
<li>
<input type="checkbox" id="dt" value="DT" />
<label class="position" for="dt">DT</label>
</li>
<li>
<input type="checkbox" id="lolb" value="LOLB" />
<label class="position" for="lolb">LOLB</label>
</li>
<li>
<input type="checkbox" id="mlb" value="MLB" />
<label class="position" for="mlb">MLB</label>
</li>
<li>
<input type="checkbox" id="rolb" value="ROLB" />
<label class="position" for="rolb">ROLB</label>
</li>
<li>
<input type="checkbox" id="cb" value="CB" />
<label class="position" for="cb">CB</label>
</li>
<li>
<input type="checkbox" id="fs" value="FS" />
<label class="position" for="fs">FS</label>
</li>
<li>
<input type="checkbox" id="ss" value="SS" />
<label class="position" for="ss">SS</label>
</li>
<li>
<input type="checkbox" id="rt" value="RT" />
<label class="position" for="rt">RT</label>
</li>
</ul>
<ul>
<li>Special Teams</li>
<li>
<input type="checkbox" id="k" value="K" />
<label class="position" for="k">K</label>
</li>
<li>
<input type="checkbox" id="p" value="P" />
<label class="position" for="p">P</label>
</li>
</ul>
</fieldset>
</form>
Here's my CSS... maybe something is conflicting.
#filters {
background: #F2F2F2;
border: 1px solid #CCCCCC;
padding: 15px;
}
.clearfix:before,
.clearfix:after {
content: " ";
display: table;
}
.clearfix:after {
clear: both;
}
.clearfix {
*zoom: 1;
}
fieldset {
border: 1px solid #ccc;
border-radius:4px;
padding: 4px;
display:inline-block;
}
.tier {
float: right;
width: 125px;
}
.position {
float: right;
width: 300px;
margin: 0 10px 0 0;
}
.position ul {
display:inline-block;
vertical-align:top;
}
input[type="radio"],
input[type="checkbox"] { position: absolute; left: -999em; }
label:before {
display: inline-block; position: relative; top:0.25em; left:-2px;
content:''; width:25px; height:25px;
background-image:url(img/formelements.png); }
input[type="checkbox"] + label:before { background-position: 0 -25px;}
input[type="checkbox"]:checked + label:before {background-position: 0 0 ; }
input[type="radio"] + label:before { background-position: -25px -25px;}
input[type="radio"]:checked + label:before { background-position: -25px 0;}
/* Remove the custom styling for IE 7-8 */
.ie8 label:before { display:none; content:none; }
.ie8 input[type="checkbox"],
.ie8 input[type="radio"],
.ie7 input[type="checkbox"],
.ie7 input[type="radio"]{
position: static; left:0; }
.ie8 input[type="checkbox"],
.ie8 input[type="radio"] {
position:relative; top:5px; margin-right:0.5em;}
input[type="text"]:focus, textarea:focus {
border-color:#000;
}

.position ul{
display: inline-block;
vertical-align: top;
}
http://jsfiddle.net/w5aFW/1

Related

CSS toggle switch group of several buttons

I'd like something like the JQuery Mobile Flip Toggle Switch, but just that, then I don't want to load all the JQuery Mobile library into my project.
Do you know how to do a nice CSS toggle buttons (more of 2 buttons) like these? I didn't find anything.
Thanks in advance!
PS: I don't care about compability with IE.
Did something quickly. Hope it will help you.
ul.tab {
list-style-type:none;
margin: 0;
padding:0;
border-radius: 5px;
}
ul.tab li {
float: left;
padding: 0;
}
ul.tab li label {
background: white;
padding: 6px;
border: 1px solid #ccc;
display: inline-block;
}
ul.tab li input[type="radio"] {
opacity: 0;
width:1px;
height:1px;
}
ul.tab li input[type="radio"]:checked ~ label {
background: red;
color: white;
}
<ul class="tab">
<li>
<input id="tab1" checked="checked" type="radio" name="tab" />
<label for="tab1">Basic</label>
</li>
<li>
<input id="tab2" type="radio" name="tab" />
<label for="tab2">Options</label>
</li>
<li>
<input id="tab3" type="radio" name="tab" />
<label for="tab3">Methods</label>
</li>
<li>
<input id="tab4" type="radio" name="tab" />
<label for="tab4">Events</label>
</li>
</ul>

Positioning chechboxes in lines, say of 4 CSS

how to use css for positioning my checkboxes in lines let's say of 4. For now the're displaying all in one line.
I tried with floating left and margin but it's not working the way I do it.
I have 7 groups of lists like below in my form
HTML:
<div class="Oobj" id="Oobj60">
<form action="mailto:kontakt#2know.pl" method="post" enctype="text/plain">
<div id="Oobj58">
<input type="checkbox" onClick="toggle(this)" /><br>
<input type="checkbox" name="sport" value="fitness" />fitness<br />
<input type="checkbox" name="sport" value="gym" />siłownia<br />
<input type="checkbox" name="sport" value="siata" />siatkówka<br />
<input type="checkbox" name="sport" value="noga" />piłka nożna<br />
<input type="checkbox" name="sport" value="kosz" />koszykówka<br />
<input type="checkbox" name="sport" value="zima" />sporty zimowe<br />
</div>
</form> </div>
CSS:
#Oobj58 {
position: absolute;
font-size: 13px;
font-family: Open Sans;
z-index: 43;
text-align: left;
left: 12.25em;
top: 23.00em;
display: none;
}
class 'Oobj' is empty. I needed it for another jq code.
try this
<div class="Oobj" id="Oobj60">
<form action="mailto:kontakt#2know.pl" method="post" enctype="text/plain">
<div id="Oobj58">
<ul>
<li> <input type="checkbox" name="sport" value="fitness" />fitness </li>
<li> <input type="checkbox" name="sport" value="gym" />siłownia</li>
<li> <input type="checkbox" name="sport" value="siata" />siatkówka</li>
<li> <input type="checkbox" name="sport" value="noga" />piłka nożna</li>
<li> <input type="checkbox" name="sport" value="kosz" />koszykówka</li>
<li> <input type="checkbox" name="sport" value="zima" />sporty zimowe</li>
</ul>
</div>
</form> </div>
#Oobj58 {
font-size: 13px;
font-family: Open Sans;
text-align: left;
left: 12.25em;
top: 23.00em;
}
#Oobj58 ul li { display:inline; margin-left:10px; }

How to format my form with CSS?

Here is the HTML for my left column:
<div id="leftcolumn">
<ul id="mainnavigation">
<li>Inicio</li>
<li>Evaluaciones</li>
<li>Docentes</li>
<li>Soporte</li>
</ul>
<div id="loginarea">
Username:
<input type="text" name="Username" />
Password:
<input type="password" name="Password" />
<input type="submit" value="Entrar" />
</div>
</div>
And here is my CSS:
#leftcolumn
{
float:left;
position:relative;
top:20px;
left:20px;
}
#leftcolumn ul#mainnavigation
{
font-size:16px;
}
#leftcolumn ul#mainnavigation li
{
padding-top:8px;
}
#leftcolumn ul#mainnavigation li a
{
text-decoration:none;
color:White;
}
#leftcolumn ul#mainnavigation li a:hover
{
text-decoration:underline;
color:Lime;
}
#loginarea
{
margin-top:20px;
}
#loginarea input
{
float:left;
}
I'm trying to have a small login form on that left navigation area and I'd like the label to be on top of their respective textbox.
Any help?
Use labels, this is what they are for
<label for="username">Username:</label>
<input type="text" name="Username" id="username" />
<label for="password">Password:</label>
<input type="password" name="Password" id="password" />
<input type="submit" value="Entrar" />
Then if you make the labels display:block they will line up on top of the inputs
I'm guessing you want the two inputs to be side by side with the label on top. If so, I would use the following HTML:
<div id="form">
<ul>
<li>
<label for="username">Username:</label>
<input type="text" name="username" id="username" />
</li><li>
<label for="password">Password:</label>
<input type="password" name="password" id="password" />
</li>
</ul>
<input type="submit" value="Entrar" id="submit" /></div>
Then float the list items and add display: block to the labels.
#form {
overflow: hidden;
}
#form li {
width: 180px;
float: left;
margin-right: 10px;
}
#form li label {
font-size: 11px;
font-weight: bold;
display: block;
margin-bottom: 2px;
}
#form #submit {
clear: both;
}
try ths::
<div id="leftcolumn">
<ul id="mainnavigation">
<li>Inicio</li>
<li>Evaluaciones</li>
<li>Docentes</li>
<li>Soporte</li>
</ul>
<div id="loginarea">
<label for="Username">Username:</label>
<input type="text" name="Username" id="Username" />
<label for="Password">Password:</label>
<input type="password" name="Password" id="Password" />
<input type="submit" value="Entrar" />
</div>
</div>​
with this css:
#leftcolumn
{
float:left;
position:relative;
top:20px;
left:20px;
}
#leftcolumn ul#mainnavigation
{
font-size:16px;
}
#leftcolumn ul#mainnavigation li
{
padding-top:8px;
}
#leftcolumn ul#mainnavigation li a
{
text-decoration:none;
color:White;
}
#leftcolumn ul#mainnavigation li a:hover
{
text-decoration:underline;
color:Lime;
}
#loginarea
{
margin-top:20px;
}
#loginarea input
{
display:block;
}
#loginarea label {
display:block;
}
​
Check out this tutorial, really helpfull for dynamic CSS.
http://articles.sitepoint.com/article/fancy-form-design-css
and some of the examples http://designshack.co.uk/articles/10-css-form-examples. They are cross browser too.

Problems with a from CSS

I am trying to create a fairly basic form with in my maincontent. I am sure I am coding things incorrectly and it is driving me crazy. Note my code. I get extremely wide vertical spacing in IE 7 and the bacground color between the field sets does not work correctly. All is good in FF.
My CSS is:
fieldset {
margin: 1.5em 0 0 0;
padding: 0;
border-style: none;
border-top: 1px solid #BFBAB0;
background-color: #FFFFFF;
}
legend {
margin-left: 1em;
color: #000000;
font-weight: bold;
}
fieldset ol {
padding: 1em 1em 0 1em;
list-style: none;
}
fieldset li {
padding-bottom: 1em;
}
fieldset.submit {
border-style: none;
}
{
var w = document.myform.mylist.selectedIndex;
var selected_text = document.myform.mylist.options[w].text;
alert(selected_text);
}
label em {
display: block;
color: #900;
font-size: 85%;
font-style: normal;
text-transform: uppercase;
}
This is my html code.
<div id="mainContent1">
<form name="myform">
<label for="mylist"><strong>Select an Account Type:</strong></label>
<select name="mylist"><option value="traditional">Traditional Account</option>
<option value="paperless">Paperless Account</option>
</select>
</form>
<br /><a> </a>
<form action="example.php">
<fieldset>
<legend>Contact Details</legend>
<ol>
<li>
<label for="name">Name:</label>
<input id="name" name="name" class="text" type="text" />
<label for="name">
<em>required</em>
</label>
</li>
<li>
<label for="email">Email address:</label>
<input id="email" name="email" class="text" type="text" />
<label for="name">
<em>required</em>
</li>
<li>
<label for="phone">Telephone:</label>
<input id="phone" name="phone" class="text" type="text" />
<label for="name">
<em>required</em>
<ol>
<li>
<input id="option1" name="option1"
class="checkbox" type="checkbox" value="1" />
<label for="option1">Savings</label>
</li>
<li>
<input id="option2" name="option2"
class="checkbox" type="checkbox" value="1" />
<label for="option2">Checkings</label>
</li>
</ol>
</fieldset>
<fieldset>
<legend>Delivery Address</legend>
<ol>
<li>
<label for="address1">Address 1:</label>
<input id="address1" name="address1" class="text"
type="text" />
</li>
<li>
<label for="city">City:</label>
<input id="city" name="city" class="text" type="text" />
</li>
<li>
<label for="postcode">Zip Code:</label>
<input id="postcode" name="postcode"
class="text textSmall" type="text" />
</li>
<li>
<label for="country">Country:</label>
<input id="country" name="country" class="text" type="text" />
</li>
</ol>
</fieldset>
<fieldset class="submit">
<input class="submit" type="submit" value="Submit" />
</fieldset>
<fieldset class="clear">
<input class="clear" type="clear"
value="Submit" />
</fieldset>
</form>
First, get rid of the script in your CSS file...
Firefox/compliant browsers and IE treat legends and fieldsets very differently, unfortunately... that may be the problem you're seeing:
http://www.456bereastreet.com/lab/styling-form-controls-revisited/fieldset/
make sure there is a "#" before your id's and a "." before your classes in your css file. not doing so causes confusion.

Inline UL element not working in IE7

Below is an entire test page that I'm working on (I realize that it is still ugly and cluttered). My issue is with the ul class="dropdown". I'm intending on it being a replacement for a SELECT so I can style it (again, not done yet). However, I cannot seem to position it where I want it. If you look at this page in FF3.5, that is how I want it to be positioned. However, in IE7, it is pushing the UL onto the next line instead of butting up against the label. I've tried numerous hacks that I've found online and none seem to help. What am I missing here?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Radix Test Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body{
margin:0;
padding:1em;
font-family:arial,sans-serif;
}
.user-form li
{
background: #fff none no-repeat bottom right;
border: 1px solid #000;
margin: 0;
padding-right: 35px;
text-align: right;
}
.user-form li label
{
background: #fff;
border: 1px solid #333;
display: -moz-inline-stack; /* Support below FF3 */
display: inline-block; /* Used only to set width */
padding: 1px 0;
width: 10em;
}
.dropdown
{
border: 1px solid #f00;
width: 20em;
padding: 0;
margin: 0;
display:inline-block;
}
.dropdown ,
.dropdown ul
{
list-style-type:none;
}
.dropdown li
{
text-align: left;
}
</style>
</head>
<body>
<form id="person.a82c3a5d-5f5e-5dbb-ae3a-14a093157dc2" class="edit-on" action="/service/testclass.php">
<fieldset>
<input id="person.a82c3a5d-5f5e-5dbb-ae3a-14a093157dc2:id" name="id" value="a82c3a5d-5f5e-5dbb-ae3a-14a093157dc2" type="hidden"/>
<ul class="user-form">
<li class="valid">
<label for="person.a82c3a5d-5f5e-5dbb-ae3a-14a093157dc2:name_prefix">Prefix:</label>
<input value="Ms." id="person.a82c3a5d-5f5e-5dbb-ae3a-14a093157dc2:name_prefix" name="name_prefix" type="hidden"/>
<ul class="dropdown">
<li>
Miss
</li>
<li class="dropcontainer">
<ul class="dropdownhidden">
<li>
</li>
<li>
Mister
</li>
<li>
Misses
</li>
<li>
Miss
</li>
<li>
Doctor
</li>
<li>
This is just a little test to see exactly how long this silly thing will make my option
</li>
</ul>
</li>
</ul>
<input name="name_prefix_value" value="Mr." type="hidden"/>
</li>
<li class="valid">
<label for="person.a82c3a5d-5f5e-5dbb-ae3a-14a093157dc2:last_name">Customer Last Name:</label>
<input id="person.a82c3a5d-5f5e-5dbb-ae3a-14a093157dc2:last_name" name="last_name" value="Jones" type="text"/>
</li>
<li class="valid">
<label for="person.a82c3a5d-5f5e-5dbb-ae3a-14a093157dc2:first_name">My First Name:</label>
<input id="person.a82c3a5d-5f5e-5dbb-ae3a-14a093157dc2:first_name" name="first_name" value="George" type="text"/>
</li>
<li class="valid">
<label for="person.a82c3a5d-5f5e-5dbb-ae3a-14a093157dc2:middle_name">Middle Name:</label>
<input id="person.a82c3a5d-5f5e-5dbb-ae3a-14a093157dc2:middle_name" name="middle_name" type="text"/>
</li>
<li class="valid">
<label for="person.a82c3a5d-5f5e-5dbb-ae3a-14a093157dc2:name_suffix">Suffix:</label>
<select id="person.a82c3a5d-5f5e-5dbb-ae3a-14a093157dc2:name_suffix" name="name_suffix">
<option value="0"/>
<option value="Jr.">Junior</option>
<option value="Sr.">Senior</option>
</select>
<input name="name_suffix_value" type="hidden"/>
</li>
<li class="invalid">
<label for="person.a82c3a5d-5f5e-5dbb-ae3a-14a093157dc2:birth_date">Date of Birth:</label>
<input id="person.a82c3a5d-5f5e-5dbb-ae3a-14a093157dc2:birth_date" name="birth_date" type="text"/>
</li>
<li class="warning">
<label for="person.a82c3a5d-5f5e-5dbb-ae3a-14a093157dc2:gender">Gender:</label>
<select id="person.a82c3a5d-5f5e-5dbb-ae3a-14a093157dc2:gender" name="gender">
<option value="0"/>
<option value="U">Unknown</option>
<option value="M">Male</option>
<option value="F">Female</option>
</select>
<input name="gender_value" type="hidden"/>
</li>
</ul>
<div class="form-actionbar">
<input name="form-edit" value="Edit" class="button-view" type="submit" disabled="disabled"/>
<input name="form-draft" value="Draft" class="button-edit" type="submit"/>
<input name="form-submit" value="Submit" class="button-edit" type="submit"/>
<input name="form-cancel" value="CancelMe" class="button-edit" type="submit"/>
<input name="form-suspend" value="Suspend" class="button" type="submit"/>
</div>
</fieldset>
</form>
</body>
</html>
Have you tried moving the hidden input field after the UL?
You can probably try putting <label> andin two separate`s in a table. Like this:
............
<fieldset>
<input id="Hidden1" name="id" value="a82c3a5d-5f5e-5dbb-ae3a-14a093157dc2"
type="hidden" />
<ul class="user-form">
<li class="valid">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="vertical-align:bottom">
<label for="person.a82c3a5d-5f5e-5dbb-ae3a-14a093157dc2:name_prefix">
Prefix:</label>
</td>
<td>
<ul class="dropdown">
<li>Miss </li>
<li class="dropcontainer">
<ul class="dropdownhidden">
<li></li>
<li>Mister </li>
<li>Misses </li>
<li>Miss </li>
<li>Doctor </li>
<li><a href="#">This is just a little test to see exactly how long this silly thing
will make my option</a></li>
</ul>
</li>
</ul>
</td>
</tr>
</table>
<input value="Ms." id="Hidden2" name="name_prefix"
type="hidden" />
<input name="name_prefix_value" value="Mr." type="hidden" />
</li>
............
With IE7, you have to follow any element with the display: inline-block; css rule with a display: inline; in a subsequent rule, usually found in an "ie lt 7" stylesheet. Is that possibly what's going on here?

Resources