2015-08-15 81 views
3

我的標題框太寬。它只應該和它內部的名爲「WEBSITE TITLE」的標題文本一樣寬。填充權太大

是否有可能讓我的填充權與我當前的填充左相同,大約5px左右?

FIDDLE這裏... 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; 
} 

回答

2

設置display: inline-blockdisplay: tableh4

.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>

+0

太好了,謝謝。一旦系統允許我接受你的答案。 – raulbaros

+0

謝謝:)看起來像'display:table'會更好,因爲它保留了問題中的邊距。 –