2009-02-22 87 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;