制作网页 为什么字体从h1改成h2,颜色就会从白色变成灰色?
时间: 2023-10-10 10:05:20 浏览: 61
这种情况可能是因为在CSS中设置了不同的样式规则,包括字体大小、颜色和行高等。默认情况下,不同的标题元素(如h1、h2、h3等)具有不同的字体大小和行高。如果您在CSS中将h1和h2标题元素的样式设置为不同的字体大小和颜色,则它们将以不同的方式呈现。如果您希望h2标题元素与h1标题元素具有相同的字体和颜色,则可以在CSS中将它们的样式设置为相同。
相关问题
帮我生成一个华丽的登录页,颜色为灰色,字体为宋体,背景为白色
好的,我可以为您生成一个华丽的登录页,颜色为灰色,字体为宋体,背景为白色。您可以使用以下代码实现:
<!DOCTYPE html>
<html>
<head>
<title>登录页</title>
<style type="text/css">
body {
background-color: white;
font-family: 宋体;
}
h1 {
color: grey;
text-align: center;
margin-top: 50px;
}
form {
margin-top: 50px;
text-align: center;
}
input[type=text], input[type=password] {
padding: 10px;
margin: 10px;
border: none;
border-radius: 5px;
box-shadow: 1px 1px 1px grey;
}
input[type=submit] {
padding: 10px 20px;
margin: 10px;
background-color: grey;
color: white;
border: none;
border-radius: 5px;
box-shadow: 1px 1px 1px grey;
cursor: pointer;
}
</style>
</head>
<body>
<h1>登录页</h1>
<form>
<label for="username">用户名:</label>
<input type="text" id="username" name="username"><br>
<label for="password">密码:</label>
<input type="password" id="password" name="password"><br>
<input type="submit" value="登录">
</form>
</body>
</html>
bootstrap3设置字体颜色为白色
要将字体颜色设置为白色,可以使用Bootstrap 3中的 `text-white` 类。这个类可以应用于任何文本元素,例如p、h1、h2等等。
以下是一个例子,将文本设置为白色:
```
<p class="text-white">这是白色的文本。</p>
```
可以在任何需要的地方使用这个类来设置字体颜色为白色。注意,这个类只能用于浅色背景,因为它将文本颜色设置为白色,如果使用在白色背景上,文本将不可见。