"跨度"选择器不工作

时间:2016-11-05 18:34:54

标签: html css

我正在尝试围绕我的H1建立一个边界但是出于某种原因我无法选择确切的" span"在CSS?我写错了什么吗?

HTML



    h1 span {
    
      display: inline-block;
      padding: 0.5em
      border: white solid 10px;
    }

<header>
  <div class="logo">
    <img src="octopus.png">
  </div>

  <nav>
    <a href="">One</a>
    <a href="">One</a>
    <a href="">One</a>
    <a href="">One</a>
  </nav>
  <h1><span>Elias</span></h1>
  <p class="kicker">Stuff // Other Stuff // More</p>
</header>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:1)

;之后你遗漏了padding,这不会让border工作

h1 span {
  display: inline-block;
  padding: 0.5em;
  border: white solid 10px;
}
/*demo*/

body {
  background: lightblue
}
<nav>
  <a href="">One</a>
  <a href="">One</a>
  <a href="">One</a>
  <a href="">One</a>
</nav>
<h1><span>Elias</span></h1>
<p class="kicker">Stuff // Other Stuff // More</p>

答案 1 :(得分:0)

CSS

span.classy {
  background-color: DodgerBlue;
}

HTML

<span class="classy">Here's a span with some text.</span>
<span>Here's another.</span>