繁体   English   中英

如何使用div创建表

[英]How to create table by using div

我想创建一个这样的表,但是使用div而不是table

<style type="text/css">
    body{ font-family:"Segoe UI", "Tahoma" }
    td {
        padding:0px 5px 10px 5px;
    }
    .username {
        white-space:nowrap;
        vertical-align:top;
        text-align:right;
        width:auto;
        color:DodgerBlue;
    }
    </style>

    <table width="500px" >
        <tr>
            <td class="username">copperfield</td>
            <td>How to create table by using div  </td>
            <td style="vertical-align:top">time </td>
        </tr>
        <tr>
            <td class="username">copperfield</td> 
            <td>
              How to create table by using div How to create table by sing div How to create table by to create table by using div <img src="images/thinking.gif"> </br>
            </td>
            <td style="vertical-align:top"> 8:00 </td>
        </tr>
        <tr>
            <td class="username"> </td> 
            <td>
               How to create table by using div</br>
            </td>
            <td style="vertical-align:top"> 8:00 </td>
        </tr>
        <tr>
            <td class="username"> </td> 
            <td>
               How to create table by using div</br>
            </td>
            <td style="vertical-align:top"> 8:00 </td>
        </tr>
        <tr>
            <td class="username">michael</td> <td><img src="images/thinking.gif"> Gi ku </td> 
            <td style="vertical-align:top"> 8:00 </td>
        </tr>
    </table>

我尝试以下代码,但未成功

   <style type="text/css">
    body{
        font-family:Segoe UI;
    }
    .all{

    float:left;
    display:block;
    }

    .chat{
    width:700px;
    float:left;
    display:table-cell;
    }

    .us{
        color:blue;
        text-align:right;
        float:left;
        margin-right:10px;

    }
    .ct{
    white-space:normal;
        float:left;
        margin-right:10px;
    }
    .t{
        float:left;
        width:auto
    }
    </style>
    <div class="all">

    <div class="chat">
        <div class="us"> userna3 46346346me </div> 
        <div  class="ct"> content </div > 
        <div class="t"> time </div>
    </div>
    <div class="chat">
        <div class="us"> copperfield </div> 
        <div class="ct"> How to create table by using div How to create table by sing div How to create table by to create table by using div</div> 
        <div class="t"> 8:00 </div>
    </div>
    <div class="chat">
        <div class="us"> copperfield </div> 
        <div  class="ct"> How to create table by using div Ho </div> 
        <div class="t"> 8:00 </div>
    </div>
</div>

看起来像您想要的: http : //jsfiddle.net/ttunW/ 关键是使用display:table; 对于.alldisplay:table-row; ,对于.chat ,取消所有div上的float:left属性,并分配display:table-cell; .chat .chatdiv

您不能在漂浮物中漂浮任何东西。 它只是不工作在一些丑陋的浏览器IE 咳嗽 咳嗽

因此,将您的CSS中的所有类更改为如下所示:

.all div {float:left;}

然后从您的班级中删除所有其他花车。 对于我们来说,ct和t只是在每个聊天div内给他们指定了宽度。 还要将聊天div的div内部更改为p标签。

如何仅使用创建表<div>标签和 Css</div><div id="text_translate"><p> 我只想使用<div>标签和 CSS 创建表格。</p><p> 这是我的示例表。</p><pre> <body> <form id="form1"> <div class="divTable"> <div class="headRow"> <div class="divCell" align="center">Customer ID</div> <div class="divCell">Customer Name</div> <div class="divCell">Customer Address</div> </div> <div class="divRow"> <div class="divCell">001</div> <div class="divCell">002</div> <div class="divCell">003</div> </div> <div class="divRow"> <div class="divCell">xxx</div> <div class="divCell">yyy</div> <div class="divCell">www</div> </div> <div class="divRow"> <div class="divCell">ttt</div> <div class="divCell">uuu</div> <div class="divCell">Mkkk</div> </div> </div> </form> </body></pre><p> 和风格:</p><pre> <style type="text/css">.divTable { display: table; width:auto; background-color:#eee; border:1px solid #666666; border-spacing:5px;/*cellspacing:poor IE support for this*/ /* border-collapse:separate;*/ }.divRow { display:table-row; width:auto; }.divCell { float:left;/*fix for buggy browsers*/ display:table-column; width:200px; background-color:#ccc; } </style></pre><p> 但是这个表不适用于IE7及以下版本。请为我提供您的解决方案和想法。 谢谢。</p></div>

[英]How create table only using <div> tag and Css

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 div 标签创建表格? 使用DIV创建表 如何使用CSS在一个div中使用多个跨度创建表 我如何创建一个 <div> 另一个表 <div> 表格使用相对宽度使用CSS? 如何使用jquery创建一个包含行的新表并将其包装在div中 如何仅使用创建表<div>标签和 Css</div><div id="text_translate"><p> 我只想使用<div>标签和 CSS 创建表格。</p><p> 这是我的示例表。</p><pre> <body> <form id="form1"> <div class="divTable"> <div class="headRow"> <div class="divCell" align="center">Customer ID</div> <div class="divCell">Customer Name</div> <div class="divCell">Customer Address</div> </div> <div class="divRow"> <div class="divCell">001</div> <div class="divCell">002</div> <div class="divCell">003</div> </div> <div class="divRow"> <div class="divCell">xxx</div> <div class="divCell">yyy</div> <div class="divCell">www</div> </div> <div class="divRow"> <div class="divCell">ttt</div> <div class="divCell">uuu</div> <div class="divCell">Mkkk</div> </div> </div> </form> </body></pre><p> 和风格:</p><pre> <style type="text/css">.divTable { display: table; width:auto; background-color:#eee; border:1px solid #666666; border-spacing:5px;/*cellspacing:poor IE support for this*/ /* border-collapse:separate;*/ }.divRow { display:table-row; width:auto; }.divCell { float:left;/*fix for buggy browsers*/ display:table-column; width:200px; background-color:#ccc; } </style></pre><p> 但是这个表不适用于IE7及以下版本。请为我提供您的解决方案和想法。 谢谢。</p></div> 如何使用 Jquery 在 DIV 标签内创建表? 如何仅使用创建表<div>标签和引导程序? 如何使用div创建表格合并 如何使用创建一个完美的5x5表 <div> 标签,看起来像使用 <table> 标签
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM