Skip to content

Instantly share code, notes, and snippets.

@Megafry
Last active September 22, 2016 19:42
Show Gist options
  • Save Megafry/848f5bd84406d0ef9331d3214049c66f to your computer and use it in GitHub Desktop.
Save Megafry/848f5bd84406d0ef9331d3214049c66f to your computer and use it in GitHub Desktop.
bootstrap 3 easy form styling
/* juste add the class defaultForm to the form Element*/
.defaultForm {
input:not([type="radio"]):not([type="checkbox"]):not([type="file"]):not([type="submit"]):not([type="reset"]),
textarea,
select {
display: block;
width: 100%;
.form-control;
&.parsley-error,
&.error {
border-color: #f00;
background-image: url("@{basePath}Images/error.svg");
background-position: right 10px center;
background-repeat: no-repeat;
& + ul {
color: #f00;
padding: 0;
li {
.list-inline;
margin-left: 15px;
}
}
}
}
fieldset {
&:disabled {
opacity: 0.5;
cursor: not-allowed;
}
&:not(.inline) {
input[type=radio], input[type=checkbox] {
+ label {
display: block;
}
}
}
margin-bottom: @form-group-margin-bottom;
}
input[type=radio], input[type=checkbox] {
display: none;
+ label {
background-image: url("@{basePath}Images/checkbox.svg");
background-position: left top;
padding-left: 25px;
background-position: left 4px;
background-repeat: no-repeat;
cursor: pointer;
margin-right: 5px;
}
&:checked + label {
background-image: url("@{basePath}Images/checkbox-check.svg");
}
}
input[type=radio] + label {
background-image: url("@{basePath}Images/radio.svg");
}
input[type=radio]:checked + label {
background-image: url("@{basePath}Images/radio-check.svg");
}
select {
&:not([multiple]){
background-image: url("@{basePath}Images/arrow.svg");
background-position: right 15px center;
background-repeat: no-repeat;
padding-right: 35px;
}
&[multiple] {
height: auto;
}
-moz-appearance: none;
&::-ms-expand {
display: none;
}
}
textarea {
resize: vertical;
min-height: 150px;
}
input[type=submit] {
.btn;
.btn-primary;
width: 100%;
margin-bottom: @form-group-margin-bottom;
}
input[type=reset] {
.btn;
.btn-default;
width: 100%;
margin-bottom: @form-group-margin-bottom;
}
input[type=file] {
display: none;
+ label{
position: relative;
width: 100%;
height: 25px;
margin-bottom: @form-group-margin-bottom + @input-height-base;
cursor: pointer;
&:after {
content: "Upload";
.btn;
.btn-primary;
width: 80px;
right: 0;
position: absolute;
margin-top: 25px;
}
&:before {
content: attr(date-filename);
.form-control;
position: absolute;
top: 0;
width: 100%;
width:calc(~'100% - 110px');
left: 0;
overflow: hidden;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin-top: 25px;
}
}
}
.input-group {
margin-bottom: @form-group-margin-bottom;
input, .input-group-btn {
margin-bottom: 0 !important;
}
}
}
.form-control {
margin-bottom: @form-group-margin-bottom;
-webkit-appearance: none;
&:disabled {
//opacity: 0.5;
}
}
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Megafry
Copy link
Author

Megafry commented Sep 22, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment