logo

NJP

Awesome Bootstrap Checkbox CSS for Service Portal

Import · Feb 11, 2019 · article

I always found it kind of ugly that ServiceNow uses unstyled checkboxes in Service-Portal. So I modified the awesome-bootstrap-checkbox CSS to add some style to Service-Portal Checkboxes.

Just add this CSS to your current Theme. And it will look like this:

image

image

.type-boolean>span>label span {
    display: inline-block;
    vertical-align: middle;
    position: relative;
    margin-left: 0px !important;
    padding-left: 5px;
}

.type-boolean>span>label span::before {
    content: "";
    display: inline-block;
    position: absolute;
    width: 17px;
    height: 17px;
    left: 0;
    margin-left: -20px;
    border: 1px solid #cccccc;
    border-radius: 3px;
    background-color: #fff;
    -webkit-transition: border 0.15s ease-in-out, color 0.15s ease-in-out;
    -o-transition: border 0.15s ease-in-out, color 0.15s ease-in-out;
    transition: border 0.15s ease-in-out, color 0.15s ease-in-out;
}

.type-boolean>span>label span::after {
    display: inline-block;
    position: absolute;
    width: 16px;
    height: 16px;
    left: 0;
    top: 0;
    margin-left: -20px;
    padding-left: 3px;
    padding-top: 1px;
    font-size: 11px;
    color: #555555;
}

.type-boolean>span>label input[type="checkbox"],
.type-boolean>span>label input[type="radio"] {
    opacity: 0;
    z-index: 1;
    cursor: pointer;
}

.type-boolean>span>label input[type="checkbox"]:focus+span::before,
.type-boolean>span>label input[type="radio"]:focus+span::before {
    outline: thin dotted;
    outline: 5px auto -webkit-focus-ring-color;
    outline-offset: -2px;
}

.type-boolean>span>label input[type="checkbox"]:checked+span::after,
.type-boolean>span>label input[type="radio"]:checked+span::after {
    font-family: "FontAwesome";
    content: "\f00c";
}

.type-boolean>span>label input[type="checkbox"]:indeterminate+span::after,
.type-boolean>span>label input[type="radio"]:indeterminate+span::after {
    display: block;
    content: "";
    width: 10px;
    height: 3px;
    background-color: #555555;
    border-radius: 2px;
    margin-left: -16.5px;
    margin-top: 7px;
}

.type-boolean>span>label input[type="checkbox"]:disabled,
.type-boolean>span>label input[type="radio"]:disabled {
    cursor: not-allowed;
}

.type-boolean>span>label input[type="checkbox"]:disabled+span,
.type-boolean>span>label input[type="radio"]:disabled+span {
    opacity: 0.65;
}

.type-boolean>span>label input[type="checkbox"]:disabled+span::before,
.type-boolean>span>label input[type="radio"]:disabled+span::before {
    background-color: #eeeeee;
    cursor: not-allowed;
}

.type-boolean>span>label.checkbox-circle span::before {
    border-radius: 50%;
}

.type-boolean>span>label.checkbox-inline {
    margin-top: 0;
}

.type-boolean>span>label input[type="checkbox"]:checked+span::after,
.type-boolean>span>label input[type="radio"]:checked+span::after {
    color: #555555;
}

.type-boolean>span>label input[type="checkbox"]:indeterminate+span::after,
.type-boolean>span>label input[type="radio"]:indeterminate+span::after {
    background-color: #555555;
}

.type-boolean>span>label.styled:checked+span:after {
    font-family: 'FontAwesome';
    content: "\f00c";
}

.type-boolean>span>label.styled:checked+span::before {
    color: #555555;
}

.type-boolean>span>label.styled:checked+span::after {
    color: #555555;
}
View original source

https://www.servicenow.com/community/developer-articles/awesome-bootstrap-checkbox-css-for-service-portal/ta-p/2330240