当我试图挤压窗户时,橱窗区域中的h1彼此重叠,但是如果不是这样,一切都很好。由于我是这个领域的新人,所以我不了解自己做错了什么。谁能告诉我需要修复的地方? html:
body {
margin: 0;
padding: 0;
background: #f4f4f4;
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
line-height: 1.6em;
}
/* GLOBAL */
.container {
width: 80%;
margin: auto;
overflow: hidden;
}
ul {
padding: 0;
margin: 0;
}
/* HEADER */
header {
background-color: #35424a;
color: #fff;
padding-top: 30px;
min-height: 70px;
border-bottom: #e8491d 3px solid;
}
header a {
color: #fff;
text-decoration: none;
text-transform: uppercase;
font-size: 17px;
}
header li {
float: left;
display: inline;
padding: 0 20px;
}
header #branding {
float: left;
}
header #branding h1 {
margin: 0;
}
header nav {
float: right;
margin-top: 10px;
}
header .highlight,
header .current a {
color: #e8491d;
font-weight: bold;
}
header a:hover {
color: #cccccc;
font-weight: bold;
}
/*Showcase*/
#showcase {
min-height: 400px;
background: url('../images/showcase.jpg') no-repeat 0 -400px;
text-align: center;
color: #fff;
}
#showcase h1 {
margin-top: 100px;
font-size: 55px;
margin-bottom: 10px;
}
#showcase p {
font-size: 17px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>ACME Web Design</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<header>
<div class="container">
<div id="branding">
<h1><span class="highlight">Acme</span> Web Design</h1>
</div>
<nav>
<ul>
<li class="current"><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="services.html">Services</a></li>
</ul>
</nav>
</div>
</header>
<section id="showcase">
<div class="container">
<h1>Affordable Professional Web Design</h1>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Illo, dolor, explicabo voluptas quibusdam dolore omnis maiores quidem necessitatibus nulla, iure ullam asperiores illum. Aliquid fuga magnam labore error vitae laborum.</p>
</div>
</section>
<section id="newsletter">
<div class="container">
<h1>Subscribe To Our Newsletter</h1>
<form action="">
<input type="email" name="email" id="" placeholder="Enter Email">
<button type="submit" class="button_1">Submit</button>
</form>
</div>
</section>
<section id="boxes">
<div class="container">
<div class="box">
<img src="images/logo_html.png" alt="">
<h1>HTML 5 Markup</h1>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Iusto quis consequuntur architecto quos ullam non dolore magni officiis. Veniam maxime labore corrupti voluptatibus! Sequi consequuntur quam laboriosam voluptatibus, at dolorum.</p>
</div>
<div class="box">
<img src="images/logo_css.png" alt="">
<h1>CSS 3 Styling</h1>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Iusto quis consequuntur architecto quos ullam non dolore magni officiis. Veniam maxime labore corrupti voluptatibus! Sequi consequuntur quam laboriosam voluptatibus, at dolorum.</p>
</div>
<div class="box">
<img src="images/logo_brush.png" alt="">
<h1>Graphic Design</h1>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Iusto quis consequuntur architecto quos ullam non dolore magni officiis. Veniam maxime labore corrupti voluptatibus! Sequi consequuntur quam laboriosam voluptatibus, at dolorum.</p>
</div>
</div>
</section>
<footer>
<p>ACME Web Design, Copyright © 2019</p>
</footer>
</body>
</html>
答案 0 :(得分:1)
您在这里有几个选择:
line-height:1.6em;
尝试将其更改为
line-height:1.6;
通常建议使用无单位的行高,因为这将允许子元素根据指定的字体大小计算其行高。 Try reading the information here for more in-depth explanation
根据您的代码,我注意到字体开始以1204px的高度堆叠,因此请尝试添加此字体:
@media screen and (max-width: 1204px) {
#showcase h1 {
font-size: 45px;
}
}
然后从此处继续测试屏幕的大小,然后根据字体开始堆叠的位置添加更多断点。
答案 1 :(得分:0)
我个人将样式line-height: 55px;
添加到#showcase h1
元素中,因此文本的高度与文本的大小相同。
这将是最终结果:
body {
margin: 0;
padding: 0;
background: #f4f4f4;
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
line-height: 1.6em;
}
/* GLOBAL */
.container {
width: 80%;
margin: auto;
overflow: hidden;
}
ul {
padding: 0;
margin: 0;
}
/* HEADER */
header {
background-color: #35424a;
color: #fff;
padding-top: 30px;
min-height: 70px;
border-bottom: #e8491d 3px solid;
}
header a {
color: #fff;
text-decoration: none;
text-transform: uppercase;
font-size: 17px;
}
header li {
float: left;
display: inline;
padding: 0 20px;
}
header #branding {
float: left;
}
header #branding h1 {
margin: 0;
}
header nav {
float: right;
margin-top: 10px;
}
header .highlight,
header .current a {
color: #e8491d;
font-weight: bold;
}
header a:hover {
color: #cccccc;
font-weight: bold;
}
/*Showcase*/
#showcase {
min-height: 400px;
background: url('../images/showcase.jpg') no-repeat 0 -400px;
text-align: center;
color: #fff;
}
#showcase h1 {
margin-top: 100px;
font-size: 55px;
margin-bottom: 10px;
line-height: 55px;
}
#showcase p {
font-size: 17px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>ACME Web Design</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<header>
<div class="container">
<div id="branding">
<h1><span class="highlight">Acme</span> Web Design</h1>
</div>
<nav>
<ul>
<li class="current"><a href="index.html">Home</a></li>
<li><a href="about.html">About</a></li>
<li><a href="services.html">Services</a></li>
</ul>
</nav>
</div>
</header>
<section id="showcase">
<div class="container">
<h1>Affordable Professional Web Design</h1>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Illo, dolor, explicabo voluptas quibusdam dolore omnis maiores quidem necessitatibus nulla, iure ullam asperiores illum. Aliquid fuga magnam labore error vitae laborum.</p>
</div>
</section>
<section id="newsletter">
<div class="container">
<h1>Subscribe To Our Newsletter</h1>
<form action="">
<input type="email" name="email" id="" placeholder="Enter Email">
<button type="submit" class="button_1">Submit</button>
</form>
</div>
</section>
<section id="boxes">
<div class="container">
<div class="box">
<img src="images/logo_html.png" alt="">
<h1>HTML 5 Markup</h1>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Iusto quis consequuntur architecto quos ullam non dolore magni officiis. Veniam maxime labore corrupti voluptatibus! Sequi consequuntur quam laboriosam voluptatibus, at dolorum.</p>
</div>
<div class="box">
<img src="images/logo_css.png" alt="">
<h1>CSS 3 Styling</h1>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Iusto quis consequuntur architecto quos ullam non dolore magni officiis. Veniam maxime labore corrupti voluptatibus! Sequi consequuntur quam laboriosam voluptatibus, at dolorum.</p>
</div>
<div class="box">
<img src="images/logo_brush.png" alt="">
<h1>Graphic Design</h1>
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Iusto quis consequuntur architecto quos ullam non dolore magni officiis. Veniam maxime labore corrupti voluptatibus! Sequi consequuntur quam laboriosam voluptatibus, at dolorum.</p>
</div>
</div>
</section>
<footer>
<p>ACME Web Design, Copyright © 2019</p>
</footer>
</body>
</html>
希望这会有所帮助。