【发布时间】:2018-03-30 06:43:33
【问题描述】:
在 .52 行上,我希望在 MIDDLE .address div 顶部的 <h2>Locations</h2> 像这样:
但是 <h2> 的 atm 只是像这样坐在左边:
而且我不知道如何将它放在中间 div 之上。
这是我的 git 存储库:https://github.com/itsolidude/Tea_Cozy
纯代码:
html {
font-family: Helvetica;
font-size: 22px;
color: seashell;
background-color: black;
opacity: 0.9;
text-align: center;
}
header {
display: flex;
align-items: center;
justify-content: space-between;
height: 69px;
border-bottom: 1px solid seashell;
position: fixed;
width: 100%;
z-index: 2;
background-color: black;
top: 0;
}
img {
height: 50px;
padding-left: 10px;
}
nav span {
color: seashell;
padding-right: 30px;
}
.mission-banner {
background-color: black;
}
.mission-banner h4 {
padding-bottom: 10px;
}
a {
cursor: pointer;
text-decoration-color: seashell;
}
#mission {
background-image: url(../images/img-mission-background.jpg);
position: relative;
margin: 70px auto 0;
width: 1200px;
height: 700px;
display: flex;
flex-direction: column;
justify-content: center;
}
#tea-of-month {
display: flex;
flex-wrap: wrap;
justify-content: center;
width: 1000px;
margin: 0 auto 70px;
}
#tea-of-month img {
height: 200px;
width: 300px;
margin-bottom: 10px;
}
.item {
display: flex;
flex-direction: column;
padding: 10px;
}
#locations {
height: 500px;
width: 1200px;
margin: 0 auto;
background-image: url(../images/img-locations-background.jpg);
display: flex;
justify-content: space-around;
align-items: center;
}
.address {
background-color: black;
width: 300px;
height: 300px;
display: flex;
flex-direction: column;
justify-content: center;
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Tea Cozy | Home</title>
<link rel="stylesheet" href="./resources/css/style.css">
</head>
<body>
<header>
<img src="./resources/images/img-tea-cozy-logo.png" alt="our logo">
<nav>
<a href="#mission"><span>Mission</span></a>
<a href="#tea-of-month"><span>Featured Tea</span></a>
<a href="#locations"><span>Locations</span></a>
</nav>
</header>
<!-- main-content,our mission -->
<div id="mission">
<div class="mission-banner">
<h2>Our Mission</h2>
<h4>Handpicked, Artisanally Curated, Free Range, Sustainable, Small Batch, Fair Trade, Organic Tea</h4>
</div>
</div>
<!-- tea of the month -->
<h2>Tea of the Month</h2> <!--ERROR HERE, ITS HIDING BEHIND THE .MISSION DIV -->
<h4>What's Steeping at The Tea Cozy?</h4>
<div id="tea-of-month">
<div class="item">
<img src="./resources/images/img-berryblitz.jpg" alt="A picture of Fall Berry Blitz Tea">
<span>Fall Berry Blitz Tea</span>
</div>
<div class="item">
<img src="./resources/images/img-spiced-rum.jpg" alt="A picture of Spiced Rum Tea">
<span>Spiced Rum Tea</span>
</div>
<div class="item">
<img src="./resources/images/img-donut.jpg" alt="A picture of Seasonal Donuts">
<span>Seasonal Donuts</span>
</div>
<div class="item">
<img src="./resources/images/img-myrtle-ave.jpg" alt="A picture of Myrtle Ave Tea">
<span>Myrtle Ave Tea</span>
</div>
<div class="item">
<img src="./resources/images/img-bedford-bizarre.jpg" alt="A picture of Bedford Bizarre Tea">
<span>Bedford Bizarre Tea</span>
</div>
</div>
<!-- locations section -->
<div id="locations">
<h2>Locations</h2>
<div class="address">
<h3>Downtown</h3>
<p>384 West 4th St</p>
<p>Suite 108</p>
<p>Portland, Maine</p>
</div>
<div class="address">
<h3>East Bayside</h3>
<p>3433 Phisherman's Avenue</p>
<p>(Northwest Corner)</p>
<p>Portland, Maine</p>
</div>
<div class="address">
<h3>Oakdale</h3>
<p>515 Crescent Avenue</p>
<p>Second Floor</p>
<p>Portland, Maine</p>
</div>
</div>
</body>
</html>
您能解释一下您这样做的原因和原因吗?
【问题讨论】:
-
太宽泛 请编辑问题以将其限制为具有足够详细信息的特定问题,以确定适当的答案。避免一次问多个不同的问题。有关澄清此问题的帮助,请参阅如何提问页面。另外:minimal reproducible example
-
@Rob 更新了它
-
你的例子不是Minimal。请将标记和 CSS 限制在您所询问的问题上。由于您询问的是
#locations,请删除其他所有内容。如果问题清晰易懂,人们可能会帮助您,因为它可能会帮助其他未来的访问者。如果它只对您有帮助,那么可能没有人会打扰。如果你不想帮助别人,我为什么要帮助你?
标签: html css flexbox positioning