我的标题框太宽了。它应该只有它里面的标题文本“网站标题”那么宽。
有没有可能让我的右垫和我现在的左垫一样,大约5倍?
在这里摆弄…FIDDLE
HTML格式:

<footer class="main_footer">
    <div class="container">
        <div class="row">
            <div class="col-sm-12">
                <div class="container-fluid">
                    <div class="text-center-footer-text">
                        <a href="#">
                            <h4>WEBSITE<span> TITLE</span></h4>
                        </a>
                    </div>
                    <p>Cool website.</p>
                    <p><a href="#">text1</a></p>
                    <p><a href="#">text2</a></p>

                </div>
            </div>
        </div>
    </div>
</footer>

CSS:
.text-center-footer-text h4 {
    font-size: 20px;
    padding: 5px;
    color: green;
    font-family: Agency FB;
    font-weight: normal;
    background-color: black;
    border: 5px solid blue;
}

.text-center-footer-text h4 span {
    color: red;
}

最佳答案

display: inline-blockdisplay: table设置为h4

.text-center-footer-text h4 {
  font-size: 20px;
  padding: 5px;
  color: green;
  font-family: Agency FB;
  font-weight: normal;
  background-color: black;
  border: 5px solid blue;
  display: inline-block;
}
.text-center-footer-text h4 span {
  color: red;
}

<footer class="main_footer">
  <div class="container">
    <div class="row">
      <div class="col-sm-12">
        <div class="container-fluid">
          <div class="text-center-footer-text">
            <a href="#">
              <h4>WEBSITE<span> TITLE</span></h4>
            </a>
          </div>
          <p>Cool website.</p>
          <p><a href="#">text1</a>
          </p>
          <p><a href="#">text2</a>
          </p>

        </div>
      </div>
    </div>
  </div>
</footer>

关于html - 右填充过大,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32028276/

10-11 00:52