Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
关于表格HTML向左浮动且始终位于顶部_Html_Css - Fatal编程技术网

关于表格HTML向左浮动且始终位于顶部

关于表格HTML向左浮动且始终位于顶部,html,css,Html,Css,目前我正在使用一个类似于下面的 <table width="45%" bgcolor="#fff" border="0" style="float: left; margin:2px;"> <tr> <td><img src="img/default.jpg" style="width:170; height:auto;"&

目前我正在使用一个类似于下面的

<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>

问题是:如何使它像这张图片一样始终位于顶部,而没有像我的第一张图片那样的空间

下面是我想要的示例表:


您只需在彼此下方使用两个
div
s,并在两个主div内为每个单元格添加其他div即可

您可以使用“div”标记,它会将您的表格分割成您想要的任何形状,您可以这样做:-

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

请在这里输入

</div>

例如,将您的除法与上面的相同格式放在一起,但是更改样式,并让清除属性像这样,这将分隔您的除法,并且不会将其附加到任何其他除法

我希望这能奏效

要将表格放在顶部,请在css文件中使用边距,将其设置为0。
**边际:0px**
看这个例子
名称
电子邮件
美孚利诺
我叫瓦伦
我的电子邮件idisvarun@gmail.com
我的手机号码是8903527945
名称
电子邮件
美孚利诺
我叫瓦伦
我的电子邮件idisvarun@gmail.com
我的手机号码是8903527945
我的电子邮件idisvarun@gmail.com
我的手机号码是8903527945
我叫瓦伦
我的电子邮件idisvarun@gmail.com
我的手机号码是8903527945
我叫瓦伦
我的电子邮件idisvarun@gmail.com
我的手机号码是8903527945
新桌子
我的电子邮件idisvarun@gmail.com
我的手机号码是8903527945
我叫瓦伦
我的电子邮件idisvarun@gmail.com
我的手机号码是8903527945
我的电子邮件idisvarun@gmail.com
我的手机号码是8903527945
我叫瓦伦
我的电子邮件idisvarun@gmail.com
我的手机号码是8903527945
我叫瓦伦
我的电子邮件idisvarun@gmail.com
我的手机号码是8903527945

和css文件

不使用表格,而是使用flexbox。
    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>