前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >html的table使用div创建

html的table使用div创建

作者头像
用户1055830
发布2018-01-18 15:45:33
2.8K0
发布2018-01-18 15:45:33
举报
文章被收录于专栏:飞扬的花生飞扬的花生

      午休时间写了一个使用div创建table的案例

1.样式

<style>
    .table {
        display: table;
    }

    .tableRow {
        display: table-row;
    }

        .tableRow div {
            display: table-cell;
            background: #EEE;
            border: 1px solid #777;
            padding: 1em;
        }
</style>

2.html和后端

<div class="table">
    <div class="tableRow">
        <div>ID</div>
        <div>姓名</div>
        <div>年龄</div>
        <div>联系方式</div>
        <div>是否已婚</div>
      
    </div>

    @foreach (var entity in Model)
    {
        <div class="tableRow">
            <div>@entity.SID</div>
            <div>@entity.SName</div>
            <div>@entity.SAge</div>         
            <div>@entity.SPhone</div>
            <div><input type="checkbox" checked="@entity.IsMarry" /></div>
        </div>
    }
</div>
  public class HomeController : Controller
    {
        //
        // GET: /Home/

        public ActionResult Index()
        {
            //组装测试数据
            IList<Student> studentList = new List<Student>()
            {             
                new Student(){ SID=1,SName="诸葛亮", SAge=60, IsMarry=true,SPhone="1111222222"},
                new Student(){ SID=2,SName="周公瑾", SAge=40, IsMarry=true,SPhone="21321321"},
                new Student(){ SID=3,SName="马孟起", SAge=30, IsMarry=true,SPhone="1111222222"},
                new Student(){ SID=4,SName="赵子龙", SAge=25, IsMarry=true,SPhone="1111222222"},
                new Student(){ SID=5,SName="关云长", SAge=31, IsMarry=true,SPhone="1111222222"},
                new Student(){ SID=5,SName="CallmeYhz", SAge=26, IsMarry=false,SPhone="355555555555"}
            };
            return View(studentList);
        }
    }

    /// <summary>
    /// 学生实体
    /// </summary>
    public class Student
    {
        public int SID { get; set; }

        public string SName { get; set; }

        public int SAge { get; set; }


        public bool IsMarry { get; set; }

        public string SPhone { get; set; }
    }

3.效果

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2016-10-11 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1.样式
  • 2.html和后端
  • 3.效果
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档