简体   繁体   中英

Glyphicons no longer supported in Bootstrap 4

I've read, from official docs, that Glyphicons were dropped from Bootstrap 4.

Today, in my searching for implementing checbox button, I've found one snippet that I appreciate very much:

Snippet for Checkbox 3.0

The problem is that this version is for Bootstrap 3.0, where Glyph were supported yet.

So I've 2 question:

  1. Wich is a good alternative to Glyphicons? Or there is a way to use them yet?
  2. How I may change the html and js snippet above to make it working wuth Bootstrap 4?

1 - Wich is a good alternative to Glyphicons? Or there is a way to use them yet?

The best alternative IMHO: http://fontawesome.io/icons/

2 - How I may change the html and js snippet above to make it working wuth Bootstrap 4?

jQuery Checkbox Buttons - Bootstrap 4

You need to change the JS:

settings = {
    on: {
        icon: 'fa fa-square-o'
    },
    off: {
        icon: 'fa fa-check-square-o'
    }
};

And the css class .hidden is now deprecated so Bootstrap recommends to use style="display: none" instead.

I agree @nerijunior Font Awesome icons is the best alternative, here is how, tested:

To use Font Awesome icons, add the following to your HTML page (No downloading or installation is required) Given Example below:

 <!DOCTYPE html> <html lang="en"> <head> <title>Bootstrap Example</title> <meta charset="utf-8"> <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous"> </head> <body> <div class="container"> <h1>My Icons <i class="fas fa-heart"></i></h1> <p>An icon along with some text: <i class="fas fa-thumbs-up"></i></p> </div> <div class="container"> <p>Others:</p> <i class="fas fa-cloud"></i> <i class="fas fa-coffee"></i> <i class="fas fa-car"></i> <i class="fas fa-file"></i> <i class="fas fa-bars"></i> </div> </body> </html>

source: https://www.w3schools.com/bootstrap4/bootstrap_icons.asp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM