前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >border、margin、padding属性的区别

border、margin、padding属性的区别

作者头像
跟着阿笨一起玩NET
发布2018-09-19 11:25:21
5490
发布2018-09-19 11:25:21
举报

可以先看下这个视频教程:http://my.tv.sohu.com/us/97014746/64226777.shtml

本文参考:http://www.cnblogs.com/chinhr/archive/2008/06/20/1227084.html

http://www.cnblogs.com/time-is-life/archive/2008/01/21/1046817.html

http://www.cnblogs.com/tianyue3107/archive/2009/04/22/1441358.html

Margin 与 Padding 的区别

1.Margin

用来设置页面中一个元素所占空间的边缘到相邻元素之间的距离.

2.Padding

用来设置元素内容到元素边界的距离。

代码语言:javascript
复制
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        .list1
        {
            width:580px;
            height:50px;
            background-color:Red;
            margin-bottom:100px;
            padding-left:10px;
            padding-right:10px;
            padding-top:10px;
        }
        .list2
        {
            width:600px;
            height:60px;
            background-color:Green;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div id="div1" class="list1">
     Div1这里 width:580px;需要用600px-10px-10px( padding-left; padding-right),才能DIV2的600px保存一致。<br/>
     Div1这里 height:60px;需要用60px-10px(减除 padding-top的内边距距离),才能高度和DIV2的60ox保持一致。
    </div>
     <div id="div2" class="list2">
     我的 width:600px;  height:30px;
    </div>
    </form>
</body>
</html>
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2014-04-20 ,如有侵权请联系 cloudcommunity@tencent.com 删除

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

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

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

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档