-
Notifications
You must be signed in to change notification settings - Fork 1.3k
CSS for simple_form
Lucas Mazza edited this page Jan 27, 2013
·
1 revision
Here is some simple CSS to style your HTML forms...
/* ----- SimpleForm Styles ----- */
.simple_form div.input {
margin-bottom: 10px;
clear: both; /* Required for Webkit, but not for Gecko */
}
.simple_form label {
float: left;
width: 100px;
text-align: right;
margin: 2px 10px;
}
div.boolean, .simple_form input[type='submit'] {
margin-left: 120px;
}
div.boolean label, label.collection_radio_buttons {
float: none;
margin: 0;
}
label.collection_radio_buttons {
margin-right: 10px;
vertical-align: -2px;
margin-left: 2px;
}
.field_with_errors {
background-color: #ff3333;
}
.simple_form .error {
clear: left;
color: black;
display: block;
margin-left: 120px;
}
.simple_form .hint {
clear: left;
margin-left: 120px;
color: #555;
display: block;
font-style: italic;
}
input.radio {
margin-right: 5px;
vertical-align: -3px;
}
input.check_boxes {
margin-left: 3px;
vertical-align: -3px;
}
label.collection_check_boxes {
float: none;
margin: 0;
vertical-align: -2px;
margin-left: 2px;
}
Or in SASS format:
/* ----- SimpleForm Styles ----- */
.simple_form
div.input
margin-bottom: 10px
clear: both
label
float: left
width: 100px
text-align: right
margin: 2px 10px
.error
clear: left
color: black
display: block
margin-left: 120px
.hint
clear: left
margin-left: 120px
color: #555
display: block
font-style: italic
div.boolean, .simple_form input[type='submit']
margin-left: 120px
div.boolean label, label.collection_radio_buttons
float: none
margin: 0
label.collection_radio_buttons
margin-right: 10px
vertical-align: -2px
margin-left: 2px
.field_with_errors
background-color: #ff3333
input.radio
margin-right: 5px
vertical-align: -3px
input.check_boxes
margin-left: 3px
vertical-align: -3px
label.collection_check_boxes
float: none
margin: 0
vertical-align: -2px
margin-left: 2px
Or in SCSS format:
.simple_form {
div.input {
margin-bottom: 10px;
clear: both;
/* Required for Webkit, but not for Gecko */
}
label {
float: left;
width: 100px;
text-align: right;
margin: 2px 10px;
}
}
div.boolean, .simple_form input[type='submit'] {
margin-left: 120px;
}
div.boolean label {
float: none;
margin: 0;
}
label.collection_radio_buttons {
float: none;
margin: 0;
margin-right: 10px;
vertical-align: -2px;
margin-left: 2px;
}
.field_with_errors {
background-color: #ff3333;
}
.simple_form {
.error {
clear: left;
color: black;
display: block;
margin-left: 120px;
}
.hint {
clear: left;
margin-left: 120px;
color: #555;
display: block;
font-style: italic;
}
}
input {
&.radio {
margin-right: 5px;
vertical-align: -3px;
}
&.check_boxes {
margin-left: 3px;
vertical-align: -3px;
}
}
label.collection_check_boxes {
float: none;
margin: 0;
vertical-align: -2px;
margin-left: 2px;
}
This page was created by the OSS community and might be outdated or incomplete. Feel free to improve or update this content according to the latest versions of SimpleForm and Rails to help the next developer who visits this wiki after you.
Keep in mind to maintain the guides as simple as possible and to avoid additional dependencies that might be specific to your application or workflow (such as Haml, RSpec, Guard and similars).