What is the most efficient way to add a tool tip to these buttons without adding more markup? Is there a way to add the tooltip content in the javascript instead of markup--. I am using some javascript to basically grab everything inside of the bs-example class so I don't want to add unnecessary markup to the screen.
.dropdown, .dropleft, .dropright, .dropup{
position: inherit;
}
.dropdown-menu.show {
width: 100%;
background: #999;
padding: 0;
margin: 0;
border-radius: 0;
border: none
}
.dropdown-menu.show {
display: inline-flex;
}
.dropdown-item {
display: inline-block;
float: left;
width: auto;
color: #fff;
padding-top: 10px;
padding-bottom: 10px;
/* color: #333;*/
}
.start {
width:141px;
padding: 20px;
}
.btn {
min-width: 200px;
}
.btn-secondary1 {
color: #fff;
background-color: #919ca7;
border-color: #6c757d;
}
.btn-secondary2 {
color: #fff;
background-color: #7d878f;
border-color: #6c757d;
}
.btn-secondary3 {
color: #fff;
background-color: #6c757d;
border-color: #5c6268;
}
.btn-secondary4 {
color: #fff;
background-color: #4a5055;
border-color: #6c757d;
}
.ms-dlgCloseBtnImg {
border-style: none !important;
max-width: inherit !important;
}
.ms-dlgTitleBtns {
margin-right: 0px;
}
.fake-underline{
text-decoration: underline;
}
.circular-image {
align-content: center;
border-radius: 50%;
width: 150px;
height: 150px;
}
.accordion {
position:relative;
background-color:white;
}
.accordion > input {
display:block;
margin:0 0;
width:100%;
height:30px;
position:relative;
cursor:pointer;
opacity:0;
filter:alpha(opacity=0);
}
.accordion > label {
display:block;
font:bold 18px/30px Arial,Sans-Serif;
background-color:#a0aec0;
color:white;
margin:-30px 0 0 0;
padding:0 15px;
}
.accordion > div {
padding:10px 15px;
display:none;
}
.accordion > input:checked + label {
background-color:slateblue;
}
.accordion > input:checked + label + div {
display:block;
}
.accordion input[type="radio"]:checked + label i.icon::before{
transform: rotate(0deg);
}
i.icon{
position: relative;
margin-top: 10px;
width: 20px;
height: 20px;
margin-right: 25px;
}
i.icon::after{
content: "";
display: block;
width: 12px;
height: 3px;
background: #fff;
top: 10px;
left: 0;
position: absolute;
}
i.icon::before{
content: "";
display: block;
width: 12px;
height: 3px;
background: #fff;
top: 10px;
left: 0;
transform: rotate(90deg);
position: absolute;
transition: all linear 0.2s;
}
.bs-example {
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<H2>tester<i style="font-size:20px;cursor:pointer;margin-left:10px;" aria-hidden="true" class="fa fa-info-circle" v-on:click="showModalZ=true"></i></H2>
<p>Please select the corresponding rating for each</p>
<div class="bs-example">
<div class="btn-group btn-group-toggle" data-toggle="buttons">
<label class="start">
<strong>1</strong>
</label>
<label class="btn btn-secondary">
<input type="radio" name="options" id="Build" autocomplete="off" v-model="test" value="1">Novice
</label>
<label class="btn btn-secondary">
<input type="radio" name="options" id="Build" autocomplete="off" v-model="test" value="1">Advanced Beginner
</label>
</div>
</div>
"Easiest" is very broad term. Read the docs:
https://getbootstrap.com/docs/4.0/components/tooltips/
The most "basic" steps:
1/3. include popper.min.js before bootstrap.js
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
2/3. Add data attributes to your markup + title :
<label data-toggle="tooltip" data-placement="bottom" title="Tooltip on bottom">
Novice
</label>
3/3. initialize
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
attribute selectors:
https://api.jquery.com/attribute-equals-selector/
Example:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<H2>Tooltip</H2>
<div class="bs-example">
<div class="btn-group btn-group-toggle" data-toggle="buttons">
<label class="start">
<strong>1</strong>
</label>
<label class="btn btn-secondary" data-toggle="tooltip" data-placement="bottom" title="Tooltip on bottom">
<input type="radio" name="options" id="Build" autocomplete="off" v-model="test" value="1">Novice
</label>
<label class="btn btn-secondary" data-toggle="tooltip" data-placement="right" title="Tooltip on right">
<input type="radio" name="options" id="Build" autocomplete="off" v-model="test" value="1">Advanced
</label>
</div>
</div>
<script>
/* https://getbootstrap.com/docs/4.0/components/tooltips/#example-enable-tooltips-everywhere */
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
</script>
"Without" any extra markup
Use:
$().tooltip(options)
Attaches a tooltip handler to an element collection.
https://getbootstrap.com/docs/4.0/components/tooltips/#tooltipoptions
<script>
$(document).ready(function(){
$(".bs-example label").tooltip({
title: "Hello tooltip."
});
});
</script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
<H2>Tooltip</H2>
<div class="bs-example">
<div class="btn-group btn-group-toggle" data-toggle="buttons">
<label class="start">
<strong>1</strong>
</label>
<label class="btn btn-secondary">
<input type="radio" name="options" id="Build" autocomplete="off" v-model="test" value="1">Novice
</label>
<label class="btn btn-secondary">
<input type="radio" name="options" id="Build" autocomplete="off" v-model="test" value="1">Advanced
</label>
</div>
</div>
<script>
$(document).ready(function(){
$(".bs-example label").tooltip({
title: "Hello tooltip."
});
});
</script>
The efficient way to use tooltip is to use existing property than re-inventing the wheel here is in bootstrap.
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="container">
Hover me
</div>
Related
I want to put icon inside the input tag but its always in the bottom of input. i used bootstrap actually but for this i used custom style
here's the html:
<div class="form-group">
<label for="password" class="text-secondary">Password</label>
<div class="input-group">
<input id="password" type="password" class="form-login #error('password') is-invalid #enderror" name="password" required autocomplete="current-password">
<div class="input-group-append">
<span class="input-group-text" onclick="password_show_hide();">
<i class="fas fa-eye" id="show_eye"></i>
<i class="fas fa-eye-slash d-none" id="hide_eye"></i>
</span>
</div>
#error('password')
<span class="invalid-feedback" role="alert">
<strong>{{ $message }}</strong>
</span>
#enderror
</div>
</div>
here's the css:
.form-login{
display: block;
width:100%;
font-size: 1rem;
font-weight: 400;
line-height:1.5;
border-color: #009DA9 !important;
border-style: solid !important;
border-width: 0 0 1px 0 !important;
padding: 0px !important;
color:black;
height: auto;
border-radius: 0;
background-color: #fff;
background-clip: padding-box;
}
.form-login:focus{
color: #495057;
background-color: #fff;
border-color: #fff;
outline: 0;
box-shadow: none;
}
what it's look like right now:
what i want to look like:
Well you can use position absolute to position the icon over the input.
You might need to change the top value a little bit and the padding-right value. Check the comment inside the snippet below
.input-group {
position:relative;
display:inline-block;
}
.input-group-text {
position: absolute;
right:0;
top: 0;
}
input {
padding-right: 20px; /* = icon width if you don't want the password to go under the icon */
}
<div class="input-group">
<input id="password" type="password" class="form-login" />
<div class="input-group-append">
<span class="input-group-text">
<i class="fas fa-eye" id="show_eye">icon</i>
</span>
</div>
</div>
You can use position absolute to position the icon over the input field. Check to code I posted below:
.form-group {
width: 50%;
position: relative;
}
.form-group i {
position: absolute;
right: 0px;
}
.icon {
padding: 10px 0px;
color: grey;
min-width: 5px;
text-align: center;
}
.input-field {
width: 100%;
padding: 10px;
border-radius: 10px;
border-color: solid lightgray;
}
<div class="form-group">
<label for="passowrd">Password</label>
<div class="input-set">
<i class="fas fa-lock icon">icon</i>
<input id="password" name="password" class="input-field" type="text" placeholder="password" />
</div>
</div>
I'm using Bootstrap in my Angular application and all other styles are working like they should, but checkbox style doesn't. It just look like plain old checkbox.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="container">
<form class="form-signin">
<h2 class="form-signin-heading">Please log in</h2>
<label for="inputEmail" class="sr-only">User name</label>
<input [(ngModel)]="loginUser.Username" type="username" name="username" id="inputEmail" class="form-control" placeholder="User name" required autofocus>
<label for="inputPassword" class="sr-only">Password</label>
<input [(ngModel)]="loginUser.Password" type="password" name="password" id="inputPassword" class="form-control" placeholder="Password" required>
<a *ngIf="register == false" (click)="registerState()">Register</a>
<div class="checkbox">
<label>
<input type="checkbox" [(ngModel)]="rememberMe" name="rememberme"> Remember me
</label>
</div>
<button *ngIf="register == false" (click)="login()" class="btn btn-lg btn-primary btn-block" type="submit">Log in</button>
</form>
</div>
What it looks like:
What I want it to look like with Bootstrap style:
Since Bootstrap 3 doesn't have a style for checkboxes I found a custom made that goes really well with Bootstrap style.
Checkboxes
.checkbox label:after {
content: '';
display: table;
clear: both;
}
.checkbox .cr {
position: relative;
display: inline-block;
border: 1px solid #a9a9a9;
border-radius: .25em;
width: 1.3em;
height: 1.3em;
float: left;
margin-right: .5em;
}
.checkbox .cr .cr-icon {
position: absolute;
font-size: .8em;
line-height: 0;
top: 50%;
left: 15%;
}
.checkbox label input[type="checkbox"] {
display: none;
}
.checkbox label input[type="checkbox"]+.cr>.cr-icon {
opacity: 0;
}
.checkbox label input[type="checkbox"]:checked+.cr>.cr-icon {
opacity: 1;
}
.checkbox label input[type="checkbox"]:disabled+.cr {
opacity: .5;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Default checkbox -->
<div class="checkbox">
<label>
<input type="checkbox" value="">
<span class="cr"><i class="cr-icon glyphicon glyphicon-ok"></i></span>
Option one
</label>
</div>
<!-- Checked checkbox -->
<div class="checkbox">
<label>
<input type="checkbox" value="" checked>
<span class="cr"><i class="cr-icon glyphicon glyphicon-ok"></i></span>
Option two is checked by default
</label>
</div>
<!-- Disabled checkbox -->
<div class="checkbox disabled">
<label>
<input type="checkbox" value="" disabled>
<span class="cr"><i class="cr-icon glyphicon glyphicon-ok"></i></span>
Option three is disabled
</label>
</div>
Radio
.checkbox label:after,
.radio label:after {
content: '';
display: table;
clear: both;
}
.checkbox .cr,
.radio .cr {
position: relative;
display: inline-block;
border: 1px solid #a9a9a9;
border-radius: .25em;
width: 1.3em;
height: 1.3em;
float: left;
margin-right: .5em;
}
.radio .cr {
border-radius: 50%;
}
.checkbox .cr .cr-icon,
.radio .cr .cr-icon {
position: absolute;
font-size: .8em;
line-height: 0;
top: 50%;
left: 13%;
}
.radio .cr .cr-icon {
margin-left: 0.04em;
}
.checkbox label input[type="checkbox"],
.radio label input[type="radio"] {
display: none;
}
.checkbox label input[type="checkbox"]+.cr>.cr-icon,
.radio label input[type="radio"]+.cr>.cr-icon {
opacity: 0;
}
.checkbox label input[type="checkbox"]:checked+.cr>.cr-icon,
.radio label input[type="radio"]:checked+.cr>.cr-icon {
opacity: 1;
}
.checkbox label input[type="checkbox"]:disabled+.cr,
.radio label input[type="radio"]:disabled+.cr {
opacity: .5;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.10/css/all.css" integrity="sha384-+d0P83n9kaQMCwj8F4RJB66tzIwOKmrdb46+porD/OvrJ+37WqIM7UoBtwHO6Nlg" crossorigin="anonymous">
<!-- Default radio -->
<div class="radio">
<label>
<input type="radio" name="o3" value="">
<span class="cr"><i class="cr-icon fa fa-circle"></i></span>
Option one
</label>
</div>
<!-- Checked radio -->
<div class="radio">
<label>
<input type="radio" name="o3" value="" checked>
<span class="cr"><i class="cr-icon fa fa-circle"></i></span>
Option two is checked by default
</label>
</div>
<!-- Disabled radio -->
<div class="radio disabled">
<label>
<input type="radio" name="o3" value="" disabled>
<span class="cr"><i class="cr-icon fa fa-circle"></i></span>
Option three is disabled
</label>
</div>
Custom icons
You can choose your own icon between the ones from Bootstrap or Font Awesome by changing [icon name] with your icon.
<span class="cr"><i class="cr-icon [icon name]"></i>
For example:
glyphicon glyphicon-remove for Bootstrap, or
fa fa-bullseye for Font Awesome
.checkbox label:after,
.radio label:after {
content: '';
display: table;
clear: both;
}
.checkbox .cr,
.radio .cr {
position: relative;
display: inline-block;
border: 1px solid #a9a9a9;
border-radius: .25em;
width: 1.3em;
height: 1.3em;
float: left;
margin-right: .5em;
}
.radio .cr {
border-radius: 50%;
}
.checkbox .cr .cr-icon,
.radio .cr .cr-icon {
position: absolute;
font-size: .8em;
line-height: 0;
top: 50%;
left: 15%;
}
.radio .cr .cr-icon {
margin-left: 0.04em;
}
.checkbox label input[type="checkbox"],
.radio label input[type="radio"] {
display: none;
}
.checkbox label input[type="checkbox"]+.cr>.cr-icon,
.radio label input[type="radio"]+.cr>.cr-icon {
opacity: 0;
}
.checkbox label input[type="checkbox"]:checked+.cr>.cr-icon,
.radio label input[type="radio"]:checked+.cr>.cr-icon {
opacity: 1;
}
.checkbox label input[type="checkbox"]:disabled+.cr,
.radio label input[type="radio"]:disabled+.cr {
opacity: .5;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.10/css/all.css" integrity="sha384-+d0P83n9kaQMCwj8F4RJB66tzIwOKmrdb46+porD/OvrJ+37WqIM7UoBtwHO6Nlg" crossorigin="anonymous">
<div class="checkbox">
<label>
<input type="checkbox" value="" checked>
<span class="cr"><i class="cr-icon glyphicon glyphicon-remove"></i></span>
Bootstrap - Custom icon checkbox
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="o3" value="" checked>
<span class="cr"><i class="cr-icon fa fa-bullseye"></i></span>
Font Awesome - Custom icon radio checked by default
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="o3" value="">
<span class="cr"><i class="cr-icon fa fa-bullseye"></i></span>
Font Awesome - Custom icon radio
</label>
</div>
You have to use Bootstrap version 4 with the custom-* classes to get this style:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- example code of the bootstrap website -->
<label class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input">
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Check this custom checkbox</span>
</label>
<!-- your code with the custom classes of version 4 -->
<div class="checkbox">
<label class="custom-control custom-checkbox">
<input type="checkbox" [(ngModel)]="rememberMe" name="rememberme" class="custom-control-input">
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Remember me</span>
</label>
</div>
Documentation: https://getbootstrap.com/docs/4.0/components/forms/#checkboxes-and-radios-1
Custom checkbox style on Bootstrap version 3?
Bootstrap version 3 doesn't have custom checkbox styles, but you can use your own. In this case: How to style a checkbox using CSS?
These custom styles are only available since version 4.
/* The customcheck */
.customcheck {
display: block;
position: relative;
padding-left: 35px;
margin-bottom: 12px;
cursor: pointer;
font-size: 22px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
/* Hide the browser's default checkbox */
.customcheck input {
position: absolute;
opacity: 0;
cursor: pointer;
}
/* Create a custom checkbox */
.checkmark {
position: absolute;
top: 0;
left: 0;
height: 25px;
width: 25px;
background-color: #eee;
border-radius: 5px;
}
/* On mouse-over, add a grey background color */
.customcheck:hover input ~ .checkmark {
background-color: #ccc;
}
/* When the checkbox is checked, add a blue background */
.customcheck input:checked ~ .checkmark {
background-color: #02cf32;
border-radius: 5px;
}
/* Create the checkmark/indicator (hidden when not checked) */
.checkmark:after {
content: "";
position: absolute;
display: none;
}
/* Show the checkmark when checked */
.customcheck input:checked ~ .checkmark:after {
display: block;
}
/* Style the checkmark/indicator */
.customcheck .checkmark:after {
left: 9px;
top: 5px;
width: 5px;
height: 10px;
border: solid white;
border-width: 0 3px 3px 0;
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
}
<div class="container">
<h1>Custom Checkboxes</h1></br>
<label class="customcheck">One
<input type="checkbox" checked="checked">
<span class="checkmark"></span>
</label>
<label class="customcheck">Two
<input type="checkbox">
<span class="checkmark"></span>
</label>
<label class="customcheck">Three
<input type="checkbox">
<span class="checkmark"></span>
</label>
<label class="customcheck">Four
<input type="checkbox">
<span class="checkmark"></span>
</label>
</div>
Here you have an example styling checkboxes and radios using Font Awesome 5 free[
/*General style*/
.custom-checkbox label, .custom-radio label {
position: relative;
cursor: pointer;
color: #666;
font-size: 30px;
}
.custom-checkbox input[type="checkbox"] ,.custom-radio input[type="radio"] {
position: absolute;
right: 9000px;
}
/*Custom checkboxes style*/
.custom-checkbox input[type="checkbox"]+.label-text:before {
content: "\f0c8";
font-family: "Font Awesome 5 Pro";
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
width: 1em;
display: inline-block;
margin-right: 5px;
}
.custom-checkbox input[type="checkbox"]:checked+.label-text:before {
content: "\f14a";
color: #2980b9;
animation: effect 250ms ease-in;
}
.custom-checkbox input[type="checkbox"]:disabled+.label-text {
color: #aaa;
}
.custom-checkbox input[type="checkbox"]:disabled+.label-text:before {
content: "\f0c8";
color: #ccc;
}
/*Custom checkboxes style*/
.custom-radio input[type="radio"]+.label-text:before {
content: "\f111";
font-family: "Font Awesome 5 Pro";
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
width: 1em;
display: inline-block;
margin-right: 5px;
}
.custom-radio input[type="radio"]:checked+.label-text:before {
content: "\f192";
color: #8e44ad;
animation: effect 250ms ease-in;
}
.custom-radio input[type="radio"]:disabled+.label-text {
color: #aaa;
}
.custom-radio input[type="radio"]:disabled+.label-text:before {
content: "\f111";
color: #ccc;
}
#keyframes effect {
0% {
transform: scale(0);
}
25% {
transform: scale(1.3);
}
75% {
transform: scale(1.4);
}
100% {
transform: scale(1);
}
}
<script src="https://kit.fontawesome.com/2a10ab39d6.js"></script>
<div class="col-md-4">
<form>
<h2>1. Customs Checkboxes</h2>
<div class="custom-checkbox">
<div class="form-check">
<label>
<input type="checkbox" name="check" checked> <span class="label-text">Option 01</span>
</label>
</div>
<div class="form-check">
<label>
<input type="checkbox" name="check"> <span class="label-text">Option 02</span>
</label>
</div>
<div class="form-check">
<label>
<input type="checkbox" name="check"> <span class="label-text">Option 03</span>
</label>
</div>
<div class="form-check">
<label>
<input type="checkbox" name="check" disabled> <span class="label-text">Option 04</span>
</label>
</div>
</div>
</form>
</div>
<div class="col-md-4">
<form>
<h2>2. Customs Radios</h2>
<div class="custom-radio">
<div class="form-check">
<label>
<input type="radio" name="radio" checked> <span class="label-text">Option 01</span>
</label>
</div>
<div class="form-check">
<label>
<input type="radio" name="radio"> <span class="label-text">Option 02</span>
</label>
</div>
<div class="form-check">
<label>
<input type="radio" name="radio"> <span class="label-text">Option 03</span>
</label>
</div>
<div class="form-check">
<label>
<input type="radio" name="radio" disabled> <span class="label-text">Option 04</span>
</label>
</div>
</div>
</form>
</div>
As others have said, the style you're after is actually just the Mac OS checkbox style, so it will look radically different on other devices.
In fact both screenshots you linked show what checkboxes look like on Mac OS in Chrome, the grey one is shown at non-100% zoom levels.
For bootstrap 5, if the switch/checkbox is not styled, add appearance in your css file.
For example:
.form-switch, .form-check {
.form-check-input {
-webkit-appearance: none;
-moz-appearance: none;
}
}
I am trying to create ON-OFF switch by referring the link
Here i can not use the FontAwesome reference in the index.html file and what i have done is i have copied the font-awesome-css file in my project. But the switch ON-OFF button is not getting displayed.
Here i have deleted the
reference from index.html and the content of font-awesome.min.css is copied on my style.css file
My requirement is to create ON-OFF switch based on the model value(Boolean).
and it should have edit (ON/OFF) feature in it.
Can anyone suggest why the css file didn't work or is there any other way i can do it .
Fontawesome simple switch
<style>
.active, .inactive {
font-size: 26px;
cursor: pointer;
}
.active, .inactive {
font-size: 26px;
cursor: pointer;
}
i.active {
color: #5cb85c;
}
i.inactive {
color: #d9534f;
}
</style>
<i class="fa fa-toggle-on" ng-class="isActive?'active':'fa-rotate-180 inactive'" ng-click="isActive=!isActive" />
"isActive"(bool) is the switch status
<html lang="en">
<head>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-animate.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-aria.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-messages.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.0.0/angular-material.min.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<script language="javascript">
angular
.module('myApp', ['ngMaterial'])
.controller('switchController', switchController);
function switchController($scope) {
$scope.data = {
switch1: true
};
$scope.message = 'false';
$scope.onChange = function(state) {
$scope.message = state;
};
}
</script>
</head>
<body ng-app="myApp">
<div id="switchContainer" ng-controller="switchController as ctrl" layout="column" ng-cloak>
<md-switch ng-model="data.switch1" aria-label="Switch 1">
Switch 1: {{ data.switch1 }}
</md-switch>
</div>
</body>
</html>
I have copied the code from https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_switch
<!DOCTYPE html>
<html>
<head>
<style>
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}
.switch input {display:none;}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: #2196F3;
}
input:focus + .slider {
box-shadow: 0 0 1px #2196F3;
}
input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
/* Rounded sliders */
.slider.round {
border-radius: 34px;
}
.slider.round:before {
border-radius: 50%;
}
</style>
</head>
<body>
<h2>Toggle Switch</h2>
<label class="switch">
<input type="checkbox">
<div class="slider"></div>
</label>
<label class="switch">
<input type="checkbox" checked>
<div class="slider"></div>
</label><br><br>
<label class="switch">
<input type="checkbox">
<div class="slider round"></div>
</label>
<label class="switch">
<input type="checkbox" checked>
<div class="slider round"></div>
</label>
</body>
</html>
I'm implementing some custom styles for radio buttons and am having problems trying to perfectly center the checked buttons. When I paste the exact same code into JS Fiddle, things work perfectly. Yet in my web app, they are each off centered (in their own way) like the image below, despite having the same classnames, positioning, etc:
Image link: Off-centered checked radio buttons
HTML:
<div class="RadioStyled">
<label class="control-label">
<input
class="form-control"
type="radio"
ref="check1"
>
<span class="radio-styled checked"></span>
<span class="label-text">Australia</span>
</label>
<div class="RadioStyled">
</div>
</div>
<div class="RadioStyled">
<label class="control-label">
<input
class="form-control"
type="radio"
ref="check2"
>
<span class="radio-styled checked"></span>
<span class="label-text">Belgium</span>
</label>
<div class="RadioStyled">
</div>
</div>
<div class="RadioStyled">
<label class="control-label">
<input
class="form-control"
type="radio"
ref="check3"
>
<span class="radio-styled checked"></span>
<span class="label-text">United Kingdom</span>
</label>
<div class="RadioStyled">
</div>
</div>
<div class="some-other-element">
<div class="RadioStyled">
<label class="control-label">
<input
class="form-control"
type="radio"
ref="check3"
>
<span class="radio-styled checked"></span>
<span class="label-text">New Zealand</span>
</label>
<div class="RadioStyled">
</div>
</div>
<div class="RadioStyled">
<label class="control-label">
<input
class="form-control"
type="radio"
ref="check3"
>
<span class="radio-styled checked"></span>
<span class="label-text">Canada</span>
</label>
<div class="RadioStyled">
</div>
</div>
</div>
CSS / SCSS:
.RadioStyled {
display: inline-block;
padding-right: 25px;
label.control-label {
cursor: pointer;
display: block;
line-height: 24px;
.label-text {
position: relative;
font-size: 14px;
color: black;
padding-left: 6px;
vertical-align: middle;
}
input[type="checkbox"], input[type="radio"] {
display: none;
}
.radio-styled {
border-radius: 50%;
border: 1px solid grey;
box-sizing: border-box;
display: inline-block;
height: 20px;
vertical-align: middle;
width: 20px;
}
.radio-styled.checked {
border: 1px solid grey;
background-color: green;
border-radius: 50%;
box-sizing: border-box;
display: inline-block;
width: 20px;
height: 20px;
vertical-align: middle;
}
.radio-styled.checked::before {
background-color: white;
border-radius: 50%;
box-sizing: border-box;
content: '';
display: inline-block;
height: 20px;
width: 20px;
// margin: -1px -1px;
transform: scale(0.5);
position: relative;
top: -1px;
right: 1px;
}
}
}
.some-other-element {
padding-left: 250px;
width: 400px;
}
Codepen here
Any idea what's happening here that makes each checked radio button seem to have a different position? Thanks!
I am trying to get a few images in a table looking alright but there is an empty input on the 3rd row and 1st column. Also the input image types look slightly bigger?
Edit: I forgot to mention this has also has to work for IE7 and up.
fiddle:
http://jsfiddle.net/486EX/
style
input {
border: 1px solid black;
}
.emptyicon {
width: 37px;
height: 37px;
float: left;
font-size: 8px;
border: 1px solid grey;
}
.sizewidth {
width: 19px;
height: 10px;
padding: 5px 3px 8px 3px;
margin: 2px;
}
.showborder {
border: 2px solid red;
}
#product {
border: 1px solid #c1c1c1;
}
.sizebtn {
margin: 2px;
height: 31px;
width: 37px;
}
.icons {
width: 213px;
float: left;
padding: 2px;
}
.icons div {
padding: 2px;
float: left;
}
.icons input {
padding: 0;
cursor: pointer;
text-align: center;
background: #FFF;
color: #000;
display: block;
height: 37px;
width: 37px;
line-height: 37px;
font-size: .6em;
overflow: hidden;
}
.sizes {
float: left;
width: 213px;
}
.sizes div {
padding: 2px 0 0 2px;
float: left;
}
.sizes input {
padding: 0;
cursor: pointer;
text-align: center;
background: #FFF;
color: #000;
display: block;
height: 30px;
width: 30px;
font-size: 1.2em;
}
html:
<div id="product">
<table>
<tbody>
<tr>
<td>
<div id="icons_7934" class="icons">
<div>
<input id="imgcolor_7934_Amethyst" text="Amethyst" class="emptyicon showborder" type="button"
value="Amethyst">
</div>
<div>
<input id="imgcolor_7934_Aquamarine" text="Aquamarine" class="emptyicon " type="button"
value="Aquamarine">
</div>
<div>
<input id="imgcolor_7934_Baby_Pink" text="Baby Pink" class="emptyicon " type="button"
value="Baby Pink">
</div>
<div>
<input id="imgcolor_7934_Biscuit" text="Biscuit" class="emptyicon " type="button"
value="Biscuit">
</div>
<div>
<input id="imgcolor_7934_Bisque" text="Bisque" class="emptyicon " type="button" value="Bisque">
</div>
<div>
<input id="imgcolor_7934_Black" src="Images/black.jpg" class="emptyicon " type="image"
value="Black">
</div>
<div>
<input id="imgcolor_7934_Burnt_Orange" text="BurntOrange" class="emptyicon " type="button"
value="BurntOrange">
</div>
<div>
<input id="imgcolor_7934_Candy" text="Candy" class="emptyicon " type="button" value="Candy">
</div>
<div>
<input id="imgcolor_7934_Cherry" text="Cherry" class="emptyicon " type="button" value="Cherry">
</div>
<div>
<input id="imgcolor_7934_Deep_Lilac" text="DeepLilac" class="emptyicon " type="button"
value="DeepLilac">
</div>
<div>
<input id="imgcolor_7934_Dusty_Rose" text="DustyRose" class="emptyicon " type="button"
value="DustyRose">
</div>
<div>
<input id="imgcolor_7934_Iceblue" text="Iceblue" class="emptyicon " type="button"
value="Iceblue">
</div>
<div>
<input id="imgcolor_7934_Lime" text="Lime" class="emptyicon " type="button" value="Lime">
</div>
<div>
<input id="imgcolor_7934_Magenta" text="Magenta" class="emptyicon " type="button"
value="Magenta">
</div>
<div>
<input id="imgcolor_7934_Navy" text="Navy" class="emptyicon " type="button" value="Navy">
</div>
<div>
<input id="imgcolor_7934_Peacock" text="Peacock" class="emptyicon " type="button"
value="Peacock">
</div>
<div>
<input id="imgcolor_7934_Royal_Blue" text="RoyalBlue" class="emptyicon " type="button"
value="RoyalBlue">
</div>
<div>
<input id="imgcolor_7934_Teal" text="Teal" class="emptyicon " type="button" value="Teal">
</div>
<div>
<input id="imgcolor_7934_White" src="Images\White.jpg" class="emptyicon " type="image"
value="White">
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<script src="Scripts/jquery-1.8.2.min.js"></script>
<script>
$("[id^='imgcolor_7934']").live("click", function () {
$("[id^='imgcolor_7934']").removeClass('showborder');
$(this).addClass("showborder");
});
</script>
I think your borders are throwing off the alignment. To correct, try using box-sizing:border-box;
Like so:
Working Example
.emptyicon {
width: 37px;
height: 37px;
float: left;
font-size: 8px;
border: 1px solid grey;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
box-sizing:border-box;
}
box-sizing documentation -MDN
If you need to support ancient IE you can use this instead:
Working Example 2
#imgcolor_7934_White, #imgcolor_7934_Black{
height:35px;
width:35px;
}
#imgcolor_7934_White.showborder, #imgcolor_7934_Black.showborder{
height:33px;
width:33px;
}