2009-02-22 82 views
1

我寫了一些HTML代碼,並且希望使用CSSHTML,CSS編輯

   <div id="contact_4" name="contact" > 
       <input type="checkbox" id="chk_4" class="contactChk"/> 
       <img height="25" width="25" alt="" src="Images/Contacts/1.jpg" style="width: 30px; height: 35px;"/> 
       <span class="contactItem" id="contactName_4" name="contactName"> 
        Amr ElGarhy 
       </span> 
       <img src="Images/Common/Motiva.png" alt=""/> 
       <br/> 
      </div> 
編輯視圖

alt text http://igurr.com/resized-image.ashx/__size/500x400/__key/CommunityServer.Components.PostAttachments/00.00.00.01.73/OneContact.JPG

什麼,我想要做的就是使文本和圖像在主DIV垂直對齊,如果有人知道如何做到這一點,而不使用任何表格,只使用CSS,並且如果我必須編輯html本身,也請指教我。

更新: 我希望在主分區中的所有東西都對齊垂直中間。正如你在圖像中看到的那樣,文本,複選框和2個圖像默認排列在底部,我想重寫。

+0

你必須更好地解釋你想要做什麼 – 2009-02-22 10:57:02

+0

垂直中間或水平中間? – 2009-02-22 11:10:39

回答

2

這樣做:

#contact_4 * {  
    vertical-align: middle; 
    display: inline; 
} 

「顯示:內聯;」如果沒有其他樣式更改這些元素顯示類型,則不需要。

P.S. div和span元素沒有「name」屬性。

0

我在CSS沒有大師,但也許把這些所有的元素會有所幫助:

margin-top: auto; 
margin-bottom: auto;