Bootstrap Tutorial Lesson Three: Create a button with an icon

Source: Internet
Author: User
Bootstrap is using the font icon glyphicons, which contains 200 icons. There are a few things to note when using font icons:
1. Each icon font is composed of a base class and a corresponding icon class, such as:
 
    <span class= "Glyphicon glyphicon-search" ></span>


2. Font icons cannot exist in conjunction with other elements and can only be used alone, using a span label and applying base classes and corresponding icon classes to spans. (as above code)
3, apply font icon span can not have any text content, also cannot have child element.
4. If you need to use text, you should add a space between the icon and the text.

Now we're officially starting with an example to make a button for a text icon. Naturally, first of all, write the HTML5 document format according to the requirement, and introduce the core files needed.

1. Create a button to add the. Btn class, this icon is called "OK", the code is as follows:

<button class= "btn" > OK </button>


2, now we want to add a checkmark icon to this button, check the font icon corresponding to. Glyphicon. Glyphicon-ok, now write these two classes to span and add them to the code:

<button class= "btn" >
        <span class= "Glyphicon glyphicon-ok" ></span> OK
    </button>


The effect is as follows:



3, you can also add the default style to this button. Btn-default, or. Btn-primary, the effect is as follows:



In the example above, the. Btn-primary class is used, the. Btn-default class style is canceled, and the font icon applied is glyphicon-remove.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.