1. 程式人生 > >Bootstrap字型圖示不顯示問題

Bootstrap字型圖示不顯示問題

問題:

bootstrap使用字型圖示時只顯示一個框,不顯示圖示。

問題分析:

出現的原因是:bootstrap.css檔案沒有正確關聯上字型檔案glyphicons-halflings-regular.eot。
檢視bootstrap.css原始碼可知:

`@font-face {
  font-family: 'Glyphicons Halflings';

  src: url('../fonts/glyphicons-halflings-regular.eot');
  src: url('../fonts/glyphicons-halflings-regular.eot?#iefix'
)
format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff2') format('woff2'), 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')
; }
`

注意當中的url

我的解決辦法:

把從網上下載的整個bootstrap丟到eclipse中。如圖
這裡寫圖片描述
在jsp頁面中的引用:

<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>bootStrap表單</title>
<script type="text/javascript" src="js/jquery.min.js"></script>
<link rel
="stylesheet" href="js/bootstrap-3.3.7-dist/css/bootstrap.css">
<script type="text/javascript" src="js/bootstrap-3.3.7-dist/js/bootstrap.js"></script> </head>

注意:jQuery的引用要放在bootstrap引用前,否則會報Uncaught Error: Bootstrap's JavaScript requires jQuery的錯誤