欧美一区二区三区,国内熟女精品熟女A片视频小说,日本av网,小鲜肉男男GAY做受XXX网站

在header標簽的末尾添加一條長長的黑線

林國瑞2年前8瀏覽0評論

我正在嘗試使用css :after pseudo class在HTML中的header標簽后添加一條黑線。代碼如下:

.container {
  max-width: 700px;
  margin: 0 auto;
  padding: 10px;
  letter-spacing: 0.07em;
  line-height: 1.5em;
  font-size: 130%;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}
h1:after {
  display: inline-block;
  content: "";
  height: 2px;
  background: black;
  width: 200px;
  margin-left: 5px;
  margin-top: 8px;
}

<div class="container">
  <h1>Lorem Ipsum</h1>
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Distinctio quia accusamus aperiam magni perspiciatis dignissimos, reiciendis dolor temporibus esse dolores quasi, reprehenderit necessitatibus culpa quas nesciunt quaerat porro! Ab, laborum.</p>
  <p>Dolorem eligendi cumque deserunt illo quas aut pariatur inventore, optio provident maxime consectetur, soluta sed, aperiam illum beatae. Quidem beatae aliquid, impedit sit in accusamus rem necessitatibus, velit fugiat! Cupiditate.</p>
</div>

使用位置:絕對;和寬度:100%會給你想要的輸出。

檢查以下內容。

.container {
  max-width: 700px;
  margin: 0 auto;
  padding: 10px;
  letter-spacing: 0.07em;
  line-height: 1.5em;
  font-size: 130%;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

h1::after {
    background: none repeat scroll 0 0 black;
    content: "";
    display: inline-block;
    height: 2px;
    margin-left: 5px;
    margin-top: 8px;
    position: absolute;
    top: 0.5em;
    width: 100%;
}
h1 {
    overflow: hidden;
    position: relative;
}

<div class="container">
  <h1>Lorem Ipsum</h1>
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Distinctio quia accusamus aperiam magni perspiciatis dignissimos, reiciendis dolor temporibus esse dolores quasi, reprehenderit necessitatibus culpa quas nesciunt quaerat porro! Ab, laborum.</p>
  <p>Dolorem eligendi cumque deserunt illo quas aut pariatur inventore, optio provident maxime consectetur, soluta sed, aperiam illum beatae. Quidem beatae aliquid, impedit sit in accusamus rem necessitatibus, velit fugiat! Cupiditate.</p>
</div>

我試圖用表格顯示屬性來解決這個問題

h1 {
 display: table;
 white-space: nowrap;
}

h1:after {
 display:table-cell;
 content: "";
 width: 100%;
 border-bottom: 2px solid black;
}

沒關系,我已經(再次)回答了我的問題

.container {
  max-width: 700px;
  margin: 0 auto;
  padding: 10px;
  letter-spacing: 0.07em;
  line-height: 1.5em;
  font-size: 130%;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

h1 {
  display: -webkit-flex;
  display: flex;
  width: 100%;
}

h1:after {
  -webkit-flex: 3;
  -flex: 3;
  display: inline-block;
  content: "";
  height: 2px;
  background: black;
  margin: auto 0 auto 5px;
}

<div class="container">
  <h1>Lorem Ipsum</h1>
  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Distinctio quia accusamus aperiam magni perspiciatis dignissimos, reiciendis dolor temporibus esse dolores quasi, reprehenderit necessitatibus culpa quas nesciunt quaerat porro! Ab, laborum.</p>
  <p>Dolorem eligendi cumque deserunt illo quas aut pariatur inventore, optio provident maxime consectetur, soluta sed, aperiam illum beatae. Quidem beatae aliquid, impedit sit in accusamus rem necessitatibus, velit fugiat! Cupiditate.</p>
</div>