【问题标题】:Underlined text despite `text-decoration: none;` and white lines on side of `<div>` section [duplicate]带下划线的文本尽管有`text-decoration:none;`和`<div>`部分旁边的白线[重复]
【发布时间】:2019-02-05 22:40:15
【问题描述】:
  1. 两侧的白线是什么? background-color: black; width: 100% 什么都不做。

  2. 为什么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 而不是pmargin:0 到正文
  • 我在divmargin: 0 中添加了body 标签,但白线仍然存在
  • 您不需要在 div 中添加 body ...您只需将 margin:0 添加到 body 并且不要忘记清除缓存

标签: html css


【解决方案1】:

您需要设置&lt;a&gt; 元素的样式以停止链接下划线:

a {
    text-decoration: none;
}

这将解决您的错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-04-17
    • 2011-10-19
    • 1970-01-01
    • 2011-11-25
    • 2014-07-29
    • 2017-04-13
    • 1970-01-01
    • 2012-04-26
    相关资源
    最近更新 更多