Ikon fon Bootstrap
Bab ini akan menerangkan ikon fon (Glyphicons) dan memahami penggunaannya melalui beberapa contoh. Bootstrap disertakan dengan glyph dalam lebih 200 format fon. Mula-mula, mari kita fahami apa itu ikon fon.
Apakah itu ikon fon?
Ikon Fon ialah fon ikon yang digunakan dalam projek web. Walaupun, Glyphicons Halflings memerlukan lesen komersial, anda boleh menggunakan ikon ini secara percuma melalui Bootstrap berasaskan projek.
Untuk menyatakan rasa terima kasih kami kepada pengarang ikon, kami berharap anda akan memasukkan pautan ke laman web GLYPHICONS apabila menggunakannya.
Dapatkan ikon fon
Kami telah memuat turun versi Bootstrap 3.x dalam bab Pemasangan Persekitaran dan memahami struktur direktorinya. Ikon fon boleh ditemui dalam folder fon, yang mengandungi fail berikut:
glyphicons-halflings-regular.eot
-
glyphicons-halflings-regular.svg
glyphicons-halflings-regular.ttf
glyphicons-halflings-regular.woff
Peraturan CSS yang berkaitan ditulis dalam bootstrap.css dan bootstrap-min dalam folder css dalam folder dist 🎜> fail.
Senarai Ikon FonKlik di sini untuk melihat senarai ikon fon yang tersedia.Penjelasan Peraturan CSSPeraturan CSS berikut membentuk kelas glyphicon.
src: url('../fonts/glyphicons-halflings-regular.eot');
src: format url('../fonts/glyphicons-halflings-regular.eot?#iefix')('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
}
.glyphicon {
kedudukan: relatif;
atas: 1px;
paparan: inline-block;
font-family: 'Glyphicons Halfings';
-webkit-font-smoothing: antialiased;
font-style: normal;
font-weight: normal;
line-height: 1;
-moz- osx-font-smoothing: skala kelabu;
}
Jadi peraturan muka fon sebenarnya mengisytiharkan keluarga fon dan kedudukan tempat glifikon ditemui. Kelas
.glyphicon mengisytiharkan kedudukan relatif mengimbangi 1px dari atas, menjadikannya sebagai blok sebaris, mengisytiharkan fon, menentukan gaya fon dan berat fon seperti biasa dan menetapkan ketinggian garisan sebagai 1. Jika tidak, gunakan -webkit-font-smoothing: antialiased dan -moz-osx-font-smoothing: grayscale; untuk konsistensi merentas penyemak imbas.
Kemudian, di sini
lebar: 1em;
}
ialah glyphicon kosong.
Terdapat 200 kelas, setiap kelas adalah untuk ikon. Format biasa kelas ini adalah seperti berikut:
kandungan: "hexvalue";
}
Contohnya , gunakan Ikon pengguna, kelasnya adalah seperti berikut:
kandungan: "e008";
}
Penggunaan
Untuk menggunakan ikon, hanya gunakan kod di bawah. Sila tinggalkan ruang yang sesuai antara ikon dan teks.
<span class="glyphicon glyphicon-search"></span>
Contoh berikut menunjukkan cara menggunakan ikon fon:
<html>
<kepala>
<tajuk>Bootstrap 实例 - 如何使你<gt; > < pautan href="http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
<script src="http://libs. baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script src="http://libs.baidu.com/bootstrap/3.0.3/js/ bootstrap.min.js"></script></head>
<badan>
<p>
<button type="button" class="btn btn-default">
<span class="glyphicon glyphicon-sort-by-attributes"></span>
</button>
<button class="btn btn-default">
<span class="glyphicon glyphicon-sort-by-attributes-alt"></span>
</button>>; < butang type="button" class="btn btn-default">
<span class="glyphicon glyphicon-sort-by-order"></span>
</button>
<button type="button" class="btn btn-default">
<span class="glyphicon glyphicon-sort-by-order-alt"></span>>;<🎜 </button>
</p>
<button type="button" class="btn btn-default btn-lg">
<span class="glyphicon glyphicon-user "></span> Pengguna
</button>
<button type="button" class="btn btn-default btn-sm">
<span class="glyphicon glyphicon-user">< ;/span> Pengguna
</button>
<button type="button" class="btn btn-default btn-xs">
<span class="glyphicon glyphicon-user">< ;/span> Pengguna
</button>
</body>
</html>
<!DOCTYPE html> <html> <head> <title>Bootstrap 实例 - 如何使用字体图标</title> <link href="http://libs.baidu.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet"> <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script> <script src="http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js"></script> </head> <body> <p> <button type="button" class="btn btn-default"> <span class="glyphicon glyphicon-sort-by-attributes"></span> </button> <button type="button" class="btn btn-default"> <span class="glyphicon glyphicon-sort-by-attributes-alt"></span> </button> <button type="button" class="btn btn-default"> <span class="glyphicon glyphicon-sort-by-order"></span> </button> <button type="button" class="btn btn-default"> <span class="glyphicon glyphicon-sort-by-order-alt"></span> </button> </p> <button type="button" class="btn btn-default btn-lg"> <span class="glyphicon glyphicon-user"></span> User </button> <button type="button" class="btn btn-default btn-sm"> <span class="glyphicon glyphicon-user"></span> User </button> <button type="button" class="btn btn-default btn-xs"> <span class="glyphicon glyphicon-user"></span> User </button> </body> </html>
Jalankan contoh »
Klik butang "Jalankan contoh" untuk melihat contoh dalam talian
带有导航栏的字体图标
<html>
t ; head<<栏的字体图标</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- >trap; --
<link href="http://apps.bdimg.com/libs/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
<style>< .
<script src="http://apps.bdimg.com/libs/html5shiv/3.7/html5shiv.min.js"></script>
<![endif]--> ;
</head>
<badan>
<div class="navbar navbar-fixed-top navbar-inverse" role="navigation">
= ; class "bekas">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=" .navbar-collapse">
<span class="sr-only">Togol navigasi</span>
<span class="t;<"gt; > <span class="icon-bar"></span>
< span class="icon-bar"></span>
t < ;a class="navbar-brand" href="#">Nama projek</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#"><span class="glyphicon glyphicon-home">Home</span></a></li>
<li><a href="#shop"><span class="glyphicon glyphicon-shopping-cart">Shop</span></a></li>
<li><a href="#support"><span class="glyphicon glyphicon-headphones">Support</span></a></li>
</ul>
</div><!-- /.nav-collapse -->
</div><!-- /.container -->
</div>
<!-- jQuery (Bootstrap 插件需要引入) -->
<script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- 包含了所有编译插件 -->
<script src="http://apps.bdimg.com/libs/bootstrap/3.2.0/js/bootstrap.min.js"></script>
</body>
</html>
实例
<!DOCTYPE html> <html> <head> <title>导航栏的字形图标</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Bootstrap --> <link href="http://apps.bdimg.com/libs/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet"> <style> body { padding-top: 50px; padding-left: 50px; } </style> <!--[if lt IE 9]> <script src="http://apps.bdimg.com/libs/html5shiv/3.7/html5shiv.min.js"></script> <![endif]--> </head> <body> <div class="navbar navbar-fixed-top navbar-inverse" role="navigation"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#">Project name</a> </div> <div class="collapse navbar-collapse"> <ul class="nav navbar-nav"> <li class="active"><a href="#"><span class="glyphicon glyphicon-home">Home</span></a></li> <li><a href="#shop"><span class="glyphicon glyphicon-shopping-cart">Shop</span></a></li> <li><a href="#support"><span class="glyphicon glyphicon-headphones">Support</span></a></li> </ul> </div><!-- /.nav-collapse --> </div><!-- /.container --> </div> <!-- jQuery (Bootstrap 插件需要引入) --> <script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script> <!-- 包含了所有编译插件 --> <script src="http://apps.bdimg.com/libs/bootstrap/3.2.0/js/bootstrap.min.js"></script> </body> </html>
Jalankan contoh »
Klik butang "Jalankan contoh" untuk melihat contoh dalam talian
定制字体图标
我们已经看到如何使用字体图标,接下来我们看看如何定制字体图标。
我们将以上面的实例开始,并通过改变字体尺寸、颜色和应用文本阴影来进行定制图标。
下面是开始的代码:
<span class="glyphicon glyphicon-user"></span> User
</button>
Sesuaikan saiz fon
Anda boleh menjadikan ikon anda kelihatan lebih besar atau lebih kecil dengan menambah atau mengurangkan saiz fonnya.
<span class="glyphicon glyphicon -user"></span> Pengguna
</button>
Warna fon tersuai
<span class="glyphicon glyphicon-user"></span> ></button>
</button>
Ikon fon tersuai dalam talian
Senarai ikon
<td
<t
ikon | nama kelas | contoh |
---|---|---|
glyphicon glyphicon-asterisk | cubalah | |
glyphicon glyphicon-plus | cubalah | |
glyphicon glyphicon-minus | Cubalah | |
glyphicon glyphicon-euro | Cubalah | |
glyphicon glyphicon-cloud | Cubalah | |
sampul surat glyphicon glyphicon | Cubalah | |
glyphicon glyphicon-pencil | Cubalah | |
glyphicon glyphicon-glass | Cubalah | |
glyphicon glyphicon-music | Cubalah | |
glyphicon glyphicon-search | Cubalah | |
glyphicon glyphicon-heart | Cubalah | |
glyphicon glyphicon -bintang | Cubalah | |
glyphicon glyphicon-star-kosong | Cubalah | |
glyphicon glyphicon-user | Cubalah | |
glyphicon glyphicon-film | Cubalah | |
glyphicon glyphicon-th-large | Cubalah | |
glyphicon glyphicon-th | Cubalah | |
glyphicon glyphicon-th-list | Cubalah | |
glyphicon glyphicon-ok | Cubalah | |
glyphicon glyphicon-remove | Cubalah | |
glyphicon glyphicon-zoom-in | Cubalah | |
glyphicon glyphicon-zoom-out | Cubalah | |
glyphicon glyphicon-off | Cubalah | |
glyphicon glyphicon-signal | Cubalah | |
glyphicon glyphicon-cog | Cubalah | |
glyphicon glyphicon-trash | Cubalah | |
glyphicon glyphicon-home | Cubalah | |
fail glyphicon glyphicon | Cubalah | |
glyphicon glyphicon -masa | Cubalah | |
glyphicon glyphicon-road | Cubalah | |
glyphicon glyphicon-download-alt | Cubalah | |
glyphicon glyphicon-muat turun | Cubalah | |
glyphicon glyphicon-upload | Cubalah | |
glyphicon glyphicon-box | Cubalah | |
glyphicon glyphicon-play-circle | Cubalah | |
glyphicon glyphicon-repeat | Cubalah | |
glyphicon glyphicon-refresh | Cubalah | |
glyphicon glyphicon-list-alt | Cubalah | |
glyphicon glyphicon-lock | Cubalah | |
glyphicon glyphicon-flag | Cubalah | |
glyphicon glyphicon-headphone | Cubalah | |
glyphicon glyphicon-volume-off | Cubalah | |
glyphicon glyphicon-volume-down | Cubalah | |
glyphicon glyphicon-volume-up | Cubalah | |
glyphicon glyphicon-qrcode | Cubalah | |
glyphicon glyphicon-barcode | Cubalah | |
glyphicon glyphicon-tag | Cubalah | |
glyphicon glyphicon-tags | Cubalah | |
glyphicon glyphicon-book | Cubalah | |
glyphicon glyphicon-bookmark | Cubalah | |
glyphicon glyphicon -cetak | Cubalah | |
kamera glyphicon glyphicon | Cubalah | |
glyphicon glyphicon-font | Cubalah | |
glyphicon glyphicon-bold | Cubalah | |
glyphicon glyphicon-italic | Cubalah | |
glyphicon glyphicon-text-height | Cubalah | |
glyphicon glyphicon-text-width | Cubalah | |
glyphicon glyphicon-align-left | Cubalah | |
glyphicon glyphicon-align-center | Cubalah | |
glyphicon glyphicon-align-right | Cubalah | |
glyphicon glyphicon-align-justify | Cubalah | |
glyphicon glyphicon-list | Cubalah | |
glyphicon glyphicon-indent-left | Cubalah | |
glyphicon glyphicon-indent-right | Cubalah | |
glyphicon glyphicon-facetime-video | Cubalah | |
gambar glyphicon glyphicon | Cubalah | |
glyphicon glyphicon-map-marker | Cubalah | |
glyphicon glyphicon-adjust | Cubalah | |
glyphicon glyphicon-tint | Cubalah | |
glyphicon glyphicon-edit | Cubalah | |
glyphicon glyphicon-share | Cubalah | |
glyphicon glyphicon-check | Cubalah | |
glyphicon glyphicon-move | Cubalah | |
glyphicon glyphicon-step-undur | Cubalah | |
glyphicon glyphicon-fast-backward | Cubalah | |
glyphicon glyphicon -ke belakang | Cuba | |
glyphicon glyphicon-play | Cuba | |
glyphicon glyphicon-pause | Cubalah | |
glyphicon glyphicon-stop | Cubalah | |
glyphicon glyphicon-forward | Cubalah | |
glyphicon glyphicon-fast-forward | Cubalah | |
glyphicon glyphicon-step-forward | Cubalah | |
glyphicon glyphicon-eject | Cubalah | |
glyphicon glyphicon-chevron-left | Cubalah | |
glyphicon glyphicon-chevron-right | Cubalah | |
glyphicon glyphicon-plus-sign | Cubalah | |
glyphicon glyphicon-minus-sign | Cubalah | |
glyphicon glyphicon-remove-sign | Cubalah | |
glyphicon glyphicon-ok-sign | cubalah | |
glyphicon glyphicon-question -tanda | Cubalah | |
glyphicon glyphicon-info-sign | Cuba | |
glyphicon glyphicon-screenshot | Cubalah | |
glyphicon glyphicon-remove-circle | Cubalah | |
glyphicon glyphicon-ok -bulatan | Cubalah | |
glyphicon glyphicon-ban-circle | Cubalah | |
glyphicon glyphicon-arrow-left | Cubalah | |
glyphicon glyphicon-arrow-right | Cubalah | |
glyphicon glyphicon -anak panah ke atas | Cubalah | |
glyphicon glyphicon-anak panah-bawah | Cubalah | |
glyphicon glyphicon-share-alt | Cubalah | |
glyphicon glyphicon-resize-full | Cubalah | |
glyphicon glyphicon-resize-small | Cubalah | |
glyphicon glyphicon-exclamation-sign | Cubalah | |
glyphicon glyphicon-gift | Cubalah | |
glyphicon glyphicon-leaf | Cubalah | |
glyphicon glyphicon-fire | Cubalah | |
glyphicon glyphicon-eye-open | Cubalah | |
glyphicon glyphicon-eye-close | Cubalah | |
glyphicon glyphicon-warning-sign | Cubalah | |
glyphicon glyphicon-plane | Cubalah | |
glyphicon glyphicon-calendar | Cubalah | |
glyphicon glyphicon-random | Cubalah | |
glyphicon glyphicon-comment | Cubalah | |
glyphicon glyphicon-magnet | cubalah | |
glyphicon glyphicon-chevron-up | cubalah | |
glyphicon glyphicon-chevron-down | Cubalah | |
glyphicon glyphicon-retweet | Cubalah | |
glyphicon glyphicon -keranjang-belanja | Cubalah | |
glyphicon glyphicon-folder-tutup | Cubalah | |
glyphicon glyphicon-folder-open | Cubalah | |
glyphicon glyphicon-resize-vertical | Cubalah | |
glyphicon glyphicon-resize-horizontal | Cubalah | |
glyphicon glyphicon-hdd | Cubalah | |
glyphicon glyphicon-bullhorn | Cubalah | |
glyphicon glyphicon-bell | Cubalah | |
glyphicon glyphicon-sijil | Cubalah | |
glyphicon glyphicon-thumbs-up | Cubalah | |
glyphicon glyphicon-thumbs-down | Cubalah | |
glyphicon glyphicon-tangan-kanan | Cuba | |
glyphicon glyphicon-hand-left | Cubalah | |
glyphicon glyphicon-hand-up | Cubalah | |
glyphicon glyphicon-hand -bawah | Cuba | |
glyphicon glyphicon-bulatan-anak panah-kanan | Cubalah | |
glyphicon glyphicon-circle-arrow-left | Cubalah | |
glyphicon glyphicon-circle-arrow-up | Cubalah | |
glyphicon glyphicon-circle-arrow-down | Cubalah | |
glyphicon glyphicon-globe | Cubalah | |
glyphicon glyphicon-wrench | Cubalah | |
glyphicon glyphicon-tasks | Cubalah | |
glyphicon glyphicon-filter | cubalah | |
glyphicon glyphicon-briefcase | cubalah | |
glyphicon glyphicon-skrin penuh | Cubalah | |
glyphicon glyphicon-dashboard | Cubalah | |
glyphicon glyphicon-paperclip | Cubalah | |
glyphicon glyphicon-heart-empty | Cubalah | |
glyphicon glyphicon-link | Cubalah | |
glyphicon glyphicon-phone | Cubalah | |
glyphicon glyphicon-pushpin | Cubalah | |
glyphicon glyphicon-usd | Cubalah | |
glyphicon glyphicon-gbp | Cubalah | |
glyphicon glyphicon-sort | Cubalah | |
glyphicon glyphicon-sort-by-abjad | Cubalah | |
glyphicon glyphicon-sort-by-alphabet-alt | Cubalah | |
glyphicon glyphicon-sort-by-order | Cubalah | |
glyphicon glyphicon-sort-by-order-alt | Cubalah | |
glyphicon glyphicon-sort-by-attributes | Cubalah | |
glyphicon glyphicon-sort-by-attributes-alt | Cubalah | |
glyphicon glyphicon-unchecked | Cubalah | |
glyphicon glyphicon-expand | Cubalah | |
glyphicon glyphicon-collapse-down | Cubalah | |
glyphicon glyphicon-collapse-up | Cubalah | |
glyphicon glyphicon-log-in | Cubalah | |
glyphicon glyphicon-flash | Cubalah | |
glyphicon glyphicon-log-out | Cubalah | |
glyphicon glyphicon-new-window | Cubalah | |
glyphicon glyphicon-record | Cubalah | |
glyphicon glyphicon-save | Cubalah | |
glyphicon glyphicon-open | Cubalah | |
glyphicon glyphicon-save | Cubalah | |