2015-11-07 52 views
-3

在我的網站上,我創建了一個側欄。但是,我想要在邊欄內容和邊欄邊框之間填充40px。我試過這個,但由於某種原因,它不起作用。這是怎麼回事?爲什麼不是我的填充工作? (HTML&CSS)

我的代碼:

.sidebar { 
 
    padding: "40px 40px 40px 40px"; 
 
}
<div id="sidebar"> 
 
    <form id="signUp" name="signUp"> 
 
     <p> 
 
      <b>Hey!</b> Want to post comments and receive cool information about me? If You Do, Sign Up Now! :D<br> 
 
      <br> 
 
      Nickname: <input id="nickname" placeholder="Nickname" required="" type="text"><br> 
 
      Email Address: <input id="email" maxlength="254" placeholder="Email Address" required="" type="text"><br> 
 
      Password: <input id="password" placeholder="Password" required="" type="password"><br> 
 
      <input onclick="confirmAccount" type="button" value="Submit"> 
 
     </p> 
 
    </form> 
 
</div>

+0

使用'#sidebar'的ID – Karan

+0

仍然沒有工作...感謝儘管建議:d –

+0

'#sidebar { 填充:40像素40像素40像素40像素; }',應該修復它 – Thaillie

回答

0

刪除你的`「的...

嘗試#sidebar { padding: 40px 40px 40px 40px; }代替

或者你可以只使用#sidebar { padding: 40px; },因爲你需要。所有方面填充40px ...

+0

對不起兄弟...仍然無法正常工作。感謝您的建議! –

0

首先你的div有一個id,所以用#而不是.。其次,從填充值中刪除引號 - 因爲它們都是相同的,所以可以只使用一個值40px。下面應該工作:

#sidebar { 
    padding: 40px; 
} 
+0

仍然無法正常工作...感謝您的建議! –

0

你已經把.sidebar放入你的css風格,這是一個與類(。)關聯的標籤。

對於ID,如側邊欄,始終使用散列(#)在CSS中標識它們。在這種情況下,您需要在代碼中放置#sidebar而不是.sidebar。

2

使用正確的選擇器(#而不是.)並刪除引號,然後這應該工作。

#sidebar { 
 
    padding: 40px 40px 40px 40px; 
 
}
<div id="sidebar"> 
 
    <form id="signUp" name="signUp"> 
 
     <p> 
 
      <b>Hey!</b> Want to post comments and receive cool information about me? If You Do, Sign Up Now! :D<br> 
 
      <br> 
 
      Nickname: <input id="nickname" placeholder="Nickname" required="" type="text"><br> 
 
      Email Address: <input id="email" maxlength="254" placeholder="Email Address" required="" type="text"><br> 
 
      Password: <input id="password" placeholder="Password" required="" type="password"><br> 
 
      <input onclick="confirmAccount" type="button" value="Submit"> 
 
     </p> 
 
    </form> 
 
</div>