【发布时间】:2019-02-05 22:40:15
【问题描述】:
两侧的白线是什么?
background-color: black; width: 100%什么都不做。为什么
p元素下面有紫色线条?我为容器设置了text-decoration: none;,为元素组设置了类,以及p本身。
#navbar {
position: fixed;
width: 100%;
top: 0;
background-color: white;
text-align: right;
}
.nav-link {
display: inline-block;
padding: 15px 15px;
text-decoration: none;
color: black;
font-size: 20px;
}
#projects {
background-color: black;
text-align: center;
width: 100%;
padding-bottom: 100px;
}
#projects h3 {
color: white;
font-size: 25px;
padding: 50px;
}
#tile-holder {
display: inline-grid;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr 1fr;
grid-column-gap: 300px;
grid-row-gap: 100px;
text-decoration: none;
}
.project-tile {
width: 100%;
border: 1px solid white;
display: flex;
flex-flow: column;
align-items: center;
}
.project-tile p {
color: white;
text-decoration: none;
}
.project-tile img {
height: 150px;
width: 288px;
}
<navbar id="navbar">
<a href="#welcome-section" class="nav-link">Welcome</a>
<a href="#projects" class="nav-link">Work</a>
<a href="#contact" class="nav-link">Contact</a>
</navbar>
<div id="projects">
<h3>Some of my work:</h3>
<div id="tile-holder">
<a href="https://codepen.io/klin-nj-97/pen/GBzjJE" target="_blank">
<div id="tribute" class="project-tile">
<p>Tribute Page</p>
<img src="https://image.ibb.co/cQGzCp/Screen_Shot_2018_08_28_at_2_33_55_PM.png" alt="tribute-page">
</div>
</a>
<a href="https://codepen.io/klin-nj-97/pen/RBmoRg" target="_blank">
<div id="survey" class="project-tile">
<p>Survey Form</p>
<img src="https://image.ibb.co/n0S6sp/Screen_Shot_2018_08_28_at_9_29_48_PM.png" alt="survey">
</div>
</a>
<a href="https://codepen.io/klin-nj-97/pen/NLPrez" target="_blank">
<div id="landing" class="project-tile">
<p>Landing Page</p>
<img src="https://image.ibb.co/n33hyU/Screen_Shot_2018_08_28_at_9_39_43_PM.png" alt="landing">
</div>
</a>
<a href="https://codepen.io/klin-nj-97/pen/bxEKex" target="_blank">
<div id="tech" class="project-tile">
<p>Technical Documentation Page</p>
<img src="https://image.ibb.co/bN4NyU/Screen_Shot_2018_08_28_at_9_41_29_PM.png" alt="tech-page">
</div>
</a>
</div>
</div>
【问题讨论】:
-
文本装饰应该转到
a而不是p和margin:0到正文 -
我在
div和margin: 0中添加了body标签,但白线仍然存在 -
您不需要在 div 中添加 body ...您只需将 margin:0 添加到 body 并且不要忘记清除缓存