gpt4 book ai didi

html - 标题随着我增加字体大小而不断降低?

转载 作者:行者123 更新时间:2023-11-28 03:56:45 25 4
gpt4 key购买 nike

下面是我的 css 文件的代码。

@-webkit-keyframes change {
83.3%,95.96% {transform:translate3d(0,-10%,0);}
}

body {
background-color: #3A457C;
}

.nav ul {
list-style: none;
background-color: #444;
text-align: center;
padding: 0;
margin: 0;
}
.nav li {
font-family: 'Oswald', sans-serif;
font-size: 1.2em;
line-height: 40px;
height: 40px;
border-bottom: 1px solid #888;
}

.nav a {
text-decoration: none;
color: #fff;
display: block;
transition: .3s background-color;
}

.nav a:hover {
background-color: #fff;
color: #444;
}

.nav a.active {
background-color: #fff;
color: #444;
cursor: default;
}

@media screen and (min-width: 600px) {
.nav li {
width: 120px;
border-bottom: none;
height: 50px;
line-height: 50px;
font-size: 1.4em;
}

/* Option 1 - Display Inline */
.nav li {
display: inline-block;
margin-right: -4px;
}

/* Options 2 - Float
.nav li {
float: left;
}
.nav ul {
overflow: auto;
width: 600px;
margin: 0 auto;
}
.nav {
background-color: #444;
}
*/
}

h1, h2, p {
font-family: 'Ubuntu', sans-serif;
color: white;
}

h1 {
font-size: 150px;
text-align: center;
-webkit-animation-name: change;
animation-duration: .5s;
line-height: 300px;
}

h2 {
font-size: 50px;
text-align: center;
}

p {
margin-left: 500px;
margin-right: 500px;
font-size: 22px;
}

.header {
cursor: pointer;
background-image: url("http://www.lib.usf.edu/tutoring/files/2015/08/Tutoring-main-banner-02.png");
background-position: center center;
height: 325px;
line-height:0px;
}

/*
#left {
position: fixed;
top: 392px;
left: 0px;
width: 25%;
height: 100%;
background-color: white;
z-index: 1;
}

#top {
position: fixed;
width: 100%;
top: 0px;
left: 0px;
right: 0px;
height:8%;
background-color: white;
}

#hardLeft {
position: fixed;
width: .35%;
top:0px;
left: 0px;
right: 0px;
height: 100%;
background-color: white;
}

#hardRight {
position: right-side;
background-color: white;
}*/

下面是html文件的代码

<!DOCTYPE html>
<html>
<div class="nav">
<ul>
<li class = "home"> <a class = "active" href = "J:\Website1\html\home\index.html">Home</a></li>
<li class = "about"> <a href = "J:\Website1\html\about\about.html">About</a></li>
</ul>
</div>

<head>
<title>Home - Tutor</title>
<link href = "J:\Website1\css\indexStyle.css" type = "text/css" rel = "stylesheet"/>
<link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet">
</head>

<body>
<div id = "background" onclick = 'window.location.href="J:\\Website1\\html\\home\\index.html"'>
<div class = "header">
<h1>Trouble? Tutor.</h1>
</div>
</div>
<h2>About</h2>
<p>My name is John Antonio Anselmo, and I currently go to Battlefield High School in Haymarket, Virginia. I'm currently enlisted in Battlefield's IT Program with a plan to study Cyber Security, Computer Science,
and Business at the Massachusetts Institute of Technology (MIT), or Virginia Tech (VT). I have exceeded in the maths and sciences since a very young age, and continue to.</p>
</body>
</html>

问题是,当我不断增加 h1 字体大小时,标题离页面顶部越来越远,我想将 h1 字体大小保持在 150px,但标题位于页面顶部这一页。看起来像 this但我希望它看起来像 this ,除了我希望 h1(麻烦?导师。)为 150px。

最佳答案

添加 margin: 0; 并将 line-height 更改为 1margin 与背景产生间隙,line-height 将文本向下移动。

@-webkit-keyframes change {
83.3%,95.96% {transform:translate3d(0,-10%,0);}
}

body {
background-color: #3A457C;
}

.nav ul {
list-style: none;
background-color: #444;
text-align: center;
padding: 0;
margin: 0;
}
.nav li {
font-family: 'Oswald', sans-serif;
font-size: 1.2em;
line-height: 40px;
height: 40px;
border-bottom: 1px solid #888;
}

.nav a {
text-decoration: none;
color: #fff;
display: block;
transition: .3s background-color;
}

.nav a:hover {
background-color: #fff;
color: #444;
}

.nav a.active {
background-color: #fff;
color: #444;
cursor: default;
}

@media screen and (min-width: 600px) {
.nav li {
width: 120px;
border-bottom: none;
height: 50px;
line-height: 50px;
font-size: 1.4em;
}

/* Option 1 - Display Inline */
.nav li {
display: inline-block;
margin-right: -4px;
}

/* Options 2 - Float
.nav li {
float: left;
}
.nav ul {
overflow: auto;
width: 600px;
margin: 0 auto;
}
.nav {
background-color: #444;
}
*/
}

h1, h2, p {
font-family: 'Ubuntu', sans-serif;
color: white;
}

h1 {
font-size:150px;
text-align: center;
-webkit-animation-name: change;
animation-duration: .5s;
line-height: 1;
margin: 0;
}

h2 {
font-size: 50px;
text-align: center;
}

p {
margin-left: 500px;
margin-right: 500px;
font-size: 22px;
}

.header {
cursor: pointer;
background-image: url("http://www.lib.usf.edu/tutoring/files/2015/08/Tutoring-main-banner-02.png");
background-position: center center;
height: 325px;
line-height:0px;
}
<html>
<div class="nav">
<ul>
<li class = "home"> <a class = "active" href = "J:\Website1\html\home\index.html">Home</a></li>
<li class = "about"> <a href = "J:\Website1\html\about\about.html">About</a></li>
</ul>
</div>

<head>
<title>Home - Tutor</title>
<link href = "J:\Website1\css\indexStyle.css" type = "text/css" rel = "stylesheet"/>
<link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet">
</head>

<body>
<div id = "background" onclick = 'window.location.href="J:\\Website1\\html\\home\\index.html"'>
<div class = "header">
<h1>Trouble? Tutor.</h1>
</div>
</div>
<h2>About</h2>
<p>My name is John Antonio Anselmo, and I currently go to Battlefield High School in Haymarket, Virginia. I'm currently enlisted in Battlefield's IT Program with a plan to study Cyber Security, Computer Science,
and Business at the Massachusetts Institute of Technology (MIT), or Virginia Tech (VT). I have exceeded in the maths and sciences since a very young age, and continue to.</p>
</body>
</html>

关于html - 标题随着我增加字体大小而不断降低?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43422226/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com