2015-01-15 68 views
1

我有同样的问题。删除表格单元格中的顶部填充

.mainDiv { 
    border-spacing: 15px; 
} 

.formDiv { 
    width: 300px; 
    background-color: #F5F6CE; 
    padding: 10px; 
    margin-left: 20px; 
    display: table-cell; 
    vertical-align: top; 
} 

.resultDiv { 

    background-color: #F5F6CE; 
    padding: 20px; 
    box-shadow: 5px 5px 5px #888888; 
    margin-left: 20px; 
    display: table-cell; 
    width: 100%; 
} 

现在,我想补充<h1>formDiv导致:

enter image description here

我希望公司注册对齐到顶部。

我发现很多线程给予回答:

vertical-align: top;

,但它不是为我工作。请帮忙。

HTML是:

<div class="mainDiv"> 
     <div class="formDiv" align="center"> 

      <h1 align="center">Company Registration</h1> 

      <form id="compReg" onsubmit="SaveData();return false;"> 
       <Table align="center" cellspacing="5px"> 
        <tr> 
         <td> 
         <Input id="txtEmail" type="email" class="text" placeholder="Contact Email" /> 
         </td> 
        </tr> 
        <!-- other input types --> 

        <tr> 
         <td> 
         <Input type="submit" value="Submit" /> 
         &nbsp; &nbsp; &nbsp; 
         <Input type="reset"/> 
         </td> 
        </tr> 

       </table> 

      </form> 
     </div> 

     <div class="resultDiv" id="result"> 
      <div align="right"> 
       <input type="button" onclick="clearData()" value="Clear" /> 
       <br> 
       <br> 
      </div> 
      <table class="dataTable" width="300"> 
       <thead> 
        <th width="20px">Id</th> 
        <th width="250px">Email</th> 

        <!-- other headers --> 

        <th width="50px">Color</th> 

       </thead> 

       <tbody id="tbody"> 

       </tbody> 
      </table> 
     </div> 

    </div> 

检查JSFiddle我想要的 “问题” H1在左格的顶部对齐。

+0

你有什么问题,你不能添加小提琴吗? – Chris

+0

请发布一个简单的例子。 (即您的标记) – jbutler483

+0

您可以发布您的HTML吗? – clami219

回答

1

h1标签都有默认的裕度。尝试将其设置为0px。

h1{ 
    margin:0px; 

} 
0

尝试重置默认的表填充和边距值

#yourtable { 
    margin: 0; 
    padding: 0; 
} 
0

你说这个?请在下次发布您的HTML标记!

h1 { margin:0; background: blue; } 
 
.formDiv { 
 
    width: 300px; 
 
    background-color: #F5F6CE; 
 
    margin-left: 20px; 
 
    padding: 0 10px 10px 10px; 
 
    display: table-cell; 
 
}
<div class="wrapper"> 
 
    <div class="formDiv"> 
 
    <h1>Lorem</h1> 
 
    <p>ipsum dolor</p> 
 
    <input name="test" type="text"> 
 
    </div> 
 
</div>

看看你提琴:http://jsfiddle.net/xsmzLb3g/2/

你必须改变h1和div的保证金/填充。

0

从我的理解,如果你正在使用表,并试图解决表格单元格间距问题。尝试使零单元格间距和单元格填充。

<table cellpadding="0" cellspacing="0"> 

CSS来H1间距

table h1{ margin:0; padding:0; } 

JSFIDDLE DEMO

+0

我不使用表格,有两个div与显示:表格单元 – SurajS

+0

请检查有问题的小提琴 – SurajS

相关问题