css - Bootstrap 3.3.1 正在影响整个页面的字体
问题描述
我正在尝试为一个特定的 div 元素添加引导程序以显示警报消息,但它会影响所有其他页面元素的字体,并且字体看起来更小。如何对页面中的一个 div 进行引导调用?
<div class="bootstrap-test">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<i class="glyphicon glyphicon-warning-sign"></i>This is a warning alert.
</div>
</div>
解决方案
在这个非常具体的情况下(与更一般的“如何将样式表链接到一个元素”问题相反,需要更多思考)如果我们查看使用的 CSS:
bootstrap 在正文中设置字体系列、字体大小等。如果您不喜欢这些,请在您自己的 css 中包含以下内容:
body{
font-family: Myspecialfont, Helvetica, sans-serif
font-size: 16px; /* or whatever you want the font size to be in the default case */
}
如果您担心警报查看引导程序希望它的外观,那么您可以将特定用途的字体大小和系列设置回引导程序 css 中的方式:
.alert-warning {
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 14px;
}
推荐阅读
- sql - Azure Blob 无法批量加载
- c# - 如何在不使用动态的情况下调用异步方法并返回结果
- batch-file - 如何使用 groovy 环境。Jenkins 中的变量以通过 Jenkins 管道中的 bat 命令
- node.js - 如何在节点js中获取表单数据和查询mongodb
- authentication - 用户通过 flask_login 获得进入权限
- python - 使用 marplotlib 绘图不会显示列表中的所有项目
- laravel - PhpStorm 找不到 Laravel 助手
- javascript - 如何在laravel中使用ajax将数据数组发送到控制器
- python - 从字典列表中查找值,其中字典具有不同数量的键
- audio - 如何使用 ffmpeg 向音频文件添加偏移或延迟?