在这种情况下如何更改字体大小?

时间:2021-06-25 17:28:24

标签: html css twitter-bootstrap

我有一个网站,主页上的横幅在查看原始 html 时看起来像

  <div class="alert alert-primary large" role="alert">Something</a><caption>More stuff</caption>

我的问题是如何增加字体大小。看起来很简单,但是将primary后面的单词改成了large、small等,并没有什么真正的变化。

请原谅我的知识不足。被赋予修改新网站的任务,到目前为止,还没有关于 css 存储位置的信息。在之前的网站(DotNetNuke)中,是一个文件夹

4 个答案:

答案 0 :(得分:1)

添加

 style="font-size:18px;"

答案 1 :(得分:1)

您不能期望仅通过在类中添加单词来使字体变大。 我看到您正在使用 Bootstrap CSS,因此请使用 https://getbootstrap.com/docs/3.4/css/ 中任何已经包含的类,或者创建您自己的类 large 定义,例如:

<style>
.large{
font-size: 24px;
}
并把它放在你的 HTML 部分

您可以内联执行此操作:

<div class="alert alert-primary" role="alert" style="font-size: 24px;">Something</a><caption>More stuff</caption>

但推荐的方法是在标题中使用 .css 文件或 <style>

答案 2 :(得分:1)

使用相应的 h1, h2, h3... 类来增加字体大小:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<div class="alert alert-primary large h3" role="alert">Something</a><caption>More stuff</caption>

答案 3 :(得分:0)

您可以使用 css 来更改元素的字体大小。 只需编辑您的代码

  <div class="alert alert-primary large" style="font-size: 50px !important;" role="alert">Something</a><caption>More stuff</caption>

或者您可以创建一个自定义类名并将其添加到您的类属性中

打开一个 <style> </style> 标签并执行类似的操作

<style>
.anyNameYouWantToUseHere{
font-size:50px !important;
}`
 </style>

  <div class="alert alert-primary large anyNameYouWantToUseHere" role="alert">Something</a><caption>More stuff</caption>

您可以将字体大小更改为您想要的任何大小。

它可以是像素或百分比,但不仅限于这两个。 我添加了重要,因为我注意到您正在使用引导程序。 我添加的 important 代码是强制元素获得指定的样式,而不管它以前的样式。

再次确保样式属性在类属性之后,否则类样式会覆盖当前样式