2016-03-01 51 views
1

我對web開發相當陌生,所以我很抱歉如果這是一個「新手」問題,我查看過各種網站並嘗試過各種各樣的事情,但無法移動按鈕在我的網頁上我想要它去的地方。嘗試向下移動頁面的另一個按鈕

這是我在HTML有它的代碼:

<div class="crown"> 
     <div class="container"> 
      <img src="http://www.clker.com/cliparts/3/8/d/6/12205466202120645650portablejim_Chess_tile_-_King_1.svg.med.png" height="250" width="200"> 
      <h3><strong>Join today!</strong></h3> 
       <p style="text-align: center;"><a class="btn-two" href="#">Register</a></p> 
      </div> 
     </div> 


    <section class="footer"> 
     <div class="container"> 
      <p>&copy; 2016</p> 
     </div> 
     </div> 

    </body> 
    </html> 

下面是它的CSS:

.btn-two { 
border: 1px solid black; 
padding: 20px; 
text-decoration: none; 
background-color: black; 
color: white; 
text-align: center; 
margin: 20px 0 -30px 0;} 

我已經嘗試了很多東西不屬於CSS加工。我希望按鈕位於「今天加入!」下方几英寸處文本,但它保持在它所在的位置,就像文本下方的頭髮,當我希望文本和按鈕之間有空格時。任何想法我做錯了什麼?再一次,我對這一切都很陌生,所以我感謝你的理解。謝謝。

+0

沒有將'a'元素顯示爲塊,邊距和填充將不會呈現。你可以在css中設置'display:inline-block',或者將填充/邊距放在按鈕父代的'p'元素上。 – shamsup

+0

在您以換行,它會很快爲您增加一些空間 – Baronz

回答

1

您必須添加display:inline-block;block.btn-two自錨元素display:inlin e。通過默認設置,margin/padding可以在不影響EM

檢查下面

.btn-two { 
 
    border: 1px solid black; 
 
    padding: 20px; 
 
    text-decoration: none; 
 
    background-color: black; 
 
    color: white; 
 
    text-align: center; 
 
    margin: 60px 0 0 0; 
 
    display: inline-block; 
 
}
I am fairly new to web development so I apologize if this is a "newbie" question, I've looked on various sites and tried various things but am not able to move a button on my page to where I want it to go. Here's the code I have for it in HTML: 
 

 
<div class="crown"> 
 
    <div class="container"> 
 
    <img src="http://www.clker.com/cliparts/3/8/d/6/12205466202120645650portablejim_Chess_tile_-_King_1.svg.med.png" height="250" width="200"> 
 
    <h3><strong>Join today!</strong></h3> 
 
    <p style="text-align: center;"><a class="btn-two" href="#">Register</a> 
 
    </p> 
 
    </div> 
 
</div> 
 

 

 
<section class="footer"> 
 
    <div class="container"> 
 
    <p>&copy; 2016</p> 
 
    </div> 
 
    </div>

0

應用display: inline-block;.btn-two。一個<a>標籤是一個內聯元素,通常不接受寬度,高度,邊距等,只要你不這樣做。

是的,如果你不想讓它居中,請從你的<p>標籤中刪除style="text-align: center;"

0

a默認情況下在瀏覽器中的元素是display:inline。內聯級別元素不能有邊距或填充,頂部或底部。您只能在元素的左側或右側應用邊距和填充。

在你的情況。我會在包含的段落元素上添加一個類,並在其頂部添加邊距。段落元素是塊級元素。

相關問題