Car*_*llo 13 twitter-bootstrap glyphicons bootstrap-4 angular
我正在使用带有Sass的Bootstrap 4进行Angular 4项目,我想使用glyphicons但是当我使用以下代码时:
<button class="btn btn-sm btn-primary"><span class="glyphicon glyphicon-thumbs-up"></span>Like</button>
Run Code Online (Sandbox Code Playgroud)
例如,在制作"喜欢"按钮时,图标不会显示.
我配置项目以使用ng-serve命令编译SCSS样式表,我angular-cli.json看起来像这样:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "front-end-informatorio"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"../node_modules/bootstrap/scss/bootstrap.scss",
"../node_modules/bootstrap/scss/main.scss"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "src/tsconfig.app.json",
"exclude": "**/node_modules/**"
},
{
"project": "src/tsconfig.spec.json",
"exclude": "**/node_modules/**"
},
{
"project": "e2e/tsconfig.e2e.json",
"exclude": "**/node_modules/**"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "scss",
"component": {}
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试在我的链接index.html:
<link data-require="bootstrap-css@3.3.6" data-semver="3.3.6" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.css"/>
Run Code Online (Sandbox Code Playgroud)
它使图标工作,但也改变了我的项目的整体风格.
如何在不重叠样式的情况下实现它?
Klo*_*ven 29
Bootstrap 4掉落了Glyphicons支持.(参见:https://getbootstrap.com/docs/4.0/migration/#components)
这意味着您需要使用其他图标字体,如Font Awesome.
<head>例:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Bootstrap + Font Awesome</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css">
<script defer src="https://use.fontawesome.com/releases/v5.0.8/js/all.js"></script>
</head>
<body>
<div class="container">
<!-- display 4 class makes the font size increase -->
<h1 class="display-4"><i class="fab fa-stack-overflow"></i></h1>
<p>That was easy! <i class="far fa-thumbs-up"></i></p>
<button type="button" class="btn btn-primary">Works also with buttons! <i class="fas fa-link"></i></button>
</div>
</body>
</html>Run Code Online (Sandbox Code Playgroud)
Font Awesome团队正在开发一个Angular Font Awesome组件.它现在正在发布,但你可以在这里找到它.
| 归档时间: |
|
| 查看次数: |
33054 次 |
| 最近记录: |