关于表格HTML向左浮动并始终在顶部

时间:2017-02-19 17:08:55

标签: html css

目前我正在使用<table>类似下面的内容

<table width="45%" bgcolor="#fff" border="0" style="float: left; margin:2px;">
  <tr>
    <td><img src="img/default.jpg" style="width:170; height:auto;"></td>
  </tr>
</table>

问题是:如何让它始终保持在最顶端,就像没有像我的第一张照片那样的空间

这里是我想要的示例表:

Here the example table what i want

3 个答案:

答案 0 :(得分:0)

你可以在彼此之下使用两个div,并为每个单元格添加两个主要div中的其他div。

答案 1 :(得分:0)

您可以使用&#34; div&#34;标签,这会将你的桌子分成你想要的任何形状,你会像这样: -

<div style="width:100px; height:auto; clear:both">

你的输入。

</div>
例如,然后用上面相同的格式划分你的鸿沟,但是改变样式并让clear属性像这样,这将分隔你的分歧,不会将它附加到任何其他分界。

我希望这会奏效。 :)

答案 2 :(得分:0)

    For placing table at the top use margin in css file set it 0 .
    **margin: 0px;**
See this example 

    <link rel="stylesheet" type="text/css" href="css/style.css">


<table border="1" class="myfirsttabel">

<thead>

    <th>Name</th>
    <th>Email</th>
    <th>Mobileno</th>


</thead>


<tbody>

<tr>

<td>    My Name is Varun</td>
<td> My email id isvarun@gmail.com</td>
<td> My Mobile No is 8903527945 </td>

</tr>


<tr>

<td>    
<table border="1" class="tabel">

<thead></thead>

    <th>Name</th>
    <th>Email</th>
    <th>Mobileno</th>


<tbody>

<tr>

<td>    My Name is Varun</td>
<td> My email id isvarun@gmail.com</td>
<td> My Mobile No is 8903527945 </td>

</tr>


<tr>

<td>    

</td>
<td> My email id isvarun@gmail.com</td>
<td> My Mobile No is 8903527945 </td>

</tr>


<tr>

<td>    My Name is Varun</td>
<td> My email id isvarun@gmail.com</td>
<td> My Mobile No is 8903527945 </td>

</tr>


<tr>

<td>    My Name is Varun</td>
<td> My email id isvarun@gmail.com</td>
<td> My Mobile No is 8903527945 </td>

</tr>
<tr>

<td>   new table</td>
<td> My email id isvarun@gmail.com</td>
<td> My Mobile No is 8903527945 </td>

</tr>


<tr>

<td>    My Name is Varun</td>
<td> My email id isvarun@gmail.com</td>
<td> My Mobile No is 8903527945 </td>

</tr>
</tbody>

</table>



</td>
<td> My email id isvarun@gmail.com</td>
<td> My Mobile No is 8903527945 </td>

</tr>


<tr>

<td>    My Name is Varun</td>
<td> My email id isvarun@gmail.com</td>
<td> My Mobile No is 8903527945 </td>

</tr>


<tr>

<td>    My Name is Varun</td>
<td> My email id isvarun@gmail.com</td>
<td> My Mobile No is 8903527945 </td>

</tr>
</tbody>

</table>

enter image description here  和css文件