CSS学习(十七)-盒模型_html/css_WEB-ITnose

php中文网
发布: 2016-06-24 11:23:45
原创
1067人浏览过

一、理论:
1.CSS盒模型
a.外盒尺寸计算--高度
element空间高度=内容高度+内距+边框+边距
b.外盒尺寸计算--宽度 element空间宽度=内容宽度+内距+边框+外距
c.内盒尺寸计算--高度
element高度=内容高度+内距+边框
d.内盒尺寸计算--宽度
element宽度=内容宽度+内距+边框
2.box-sizing
a.content-box 默认值
b.border-box 元素维持IE传统的盒模型
c.inherit 使元素继承父元素的盒模型模式 
d.此值主要目的是控制元素的总宽度

二、实践:

1.

立即学习前端免费学习笔记(深入)”;

可图大模型
可图大模型

可图大模型(Kolors)是快手大模型团队自研打造的文生图AI大模型

可图大模型 32
查看详情 可图大模型
<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>Title</title>    <style type="text/css" >        *{            margin: 0;            padding: 0;        }        .wrapper{            width: 960px;            margin-left: auto;            margin-right: auto;            color:#6bb2ff;            font-size: 30px;            text-align: center;        }        #header{            height: 100px;            background: #228833;            margin-bottom: 10px;        }        .sidebar{            float:left;            width: 220px;            margin-right: 20px;            margin-bottom: 10px;            height: 300px;            background: #ebf3fc;        }        .content{            float:left;            width: 720px;            height: 300px;            background: #ffcc99;            margin-bottom: 10px;        }        #footer{            background: #a6f821;            height: 100px;            clear: both;        }    </style></head><body>    <div class="wrapper">        <div id="header">hedaer</div>        <div class="sidebar">left</div>        <div class="content">main</div>        <div id="footer">footer</div>    </div></body></html>
登录后复制
2.

立即学习前端免费学习笔记(深入)”;

立即学习前端免费学习笔记(深入)”;

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>Title</title>    <style type="text/css" >        *{            margin: 0;            padding: 0;        }        .wrapper{            width: 960px;            margin-left: auto;            margin-right: auto;            color:#6bb2ff;            font-size: 30px;            text-align: center;            background: #ffcc99;        }        #header{            height: 100px;            background: #228833;            margin-bottom: 10px;            padding: 10px;            width: 100%;        }        .sidebar{            float:left;            width: 220px;            margin-right: 20px;            margin-bottom: 10px;            height: 300px;            background: #ebf3fc;            padding: 10px;        }        .content{            float:left;            width: 720px;            height: 300px;            background: #ffcc99;            margin-bottom: 10px;            padding: 10px;        }        #footer{            background: #a6f821;            height: 100px;            clear: both;            padding: 10px;            width: 100%;        }    </style></head><body>    <div class="wrapper">        <div id="header">hedaer</div>        <div class="sidebar">left</div>        <div class="content">main</div>        <div id="footer">footer</div>    </div></body></html>
登录后复制
3.

立即学习前端免费学习笔记(深入)”;

立即学习前端免费学习笔记(深入)”;

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>Title</title>    <style type="text/css" >        *{            margin: 0;            padding: 0;        }        .wrapper{            width: 960px;            margin-left: auto;            margin-right: auto;            color:#6bb2ff;            font-size: 30px;            text-align: center;            background: #ffcc99;        }        #header{            height: 100px;            background: #228833;            margin-bottom: 10px;            padding: 10px;            width: 100%;            border: 10px solid darkgray;        }        .sidebar{            float:left;            width: 220px;            margin-right: 20px;            margin-bottom: 10px;            height: 300px;            background: #ebf3fc;            padding: 10px;            border: 10px solid red;        }        .content{            float:left;            width: 720px;            height: 300px;            background: #ffcc99;            margin-bottom: 10px;            padding: 10px;            border: 10px solid chartreuse;        }        #footer{            background: #a6f821;            height: 100px;            clear: both;            padding: 10px;            width: 100%;            border: 10px solid #202189;        }    </style></head><body>    <div class="wrapper">        <div id="header">hedaer</div>        <div class="sidebar">left</div>        <div class="content">main</div>        <div id="footer">footer</div>    </div></body></html>
登录后复制
4.

立即学习前端免费学习笔记(深入)”;

立即学习前端免费学习笔记(深入)”;

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>Title</title>    <style type="text/css" >        *{            margin: 0;            padding: 0;        }        .wrapper{            width: 960px;            margin-left: auto;            margin-right: auto;            color:#6bb2ff;            font-size: 30px;            text-align: center;            background: #ffcc99;        }        #header{            height: 100px;            background: #228833;            margin-bottom: 10px;            padding: 10px;            width: 100%;            border: 10px solid darkgray;            -moz-box-sizing: border-box;            -webkit-box-sizing: border-box;            -o-box-sizing:border-box;            -ma-box-sizing:border-box;            box-sizing: border-box;        }        .sidebar{            float:left;            width: 220px;            margin-right: 20px;            margin-bottom: 10px;            height: 300px;            background: #ebf3fc;            padding: 10px;            border: 10px solid red;            -moz-box-sizing: border-box;            -webkit-box-sizing: border-box;            -o-box-sizing:border-box;            -ma-box-sizing:border-box;            box-sizing: border-box;        }        .content{            float:left;            width: 720px;            height: 300px;            background: #ffcc99;            margin-bottom: 10px;            padding: 10px;            border: 10px solid chartreuse;            -moz-box-sizing: border-box;            -webkit-box-sizing: border-box;            -o-box-sizing:border-box;            -ma-box-sizing:border-box;            box-sizing: border-box;        }        #footer{            background: #a6f821;            height: 100px;            clear: both;            padding: 10px;            width: 100%;            border: 10px solid #202189;            -moz-box-sizing: border-box;            -webkit-box-sizing: border-box;            -o-box-sizing:border-box;            -ma-box-sizing:border-box;            box-sizing: border-box;        }    </style></head><body>    <div class="wrapper">        <div id="header">hedaer</div>        <div class="sidebar">left</div>        <div class="content">main</div>        <div id="footer">footer</div>    </div></body></html>
登录后复制


立即学习前端免费学习笔记(深入)”;

HTML速学教程(入门课程)
HTML速学教程(入门课程)

HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号