CSS盒子模型
1.盒子的概念
css盒子本质上上是一个盒子,由内容区域(height)内间距区域(padding)边框区域(borde外边距区域(margin)组成, 下图可示。
2.布局方式
2.1外部显示类型
2.1.1块级盒子
<div/> <p/> <h1/> display:block 水平垂直都会挤占空间
2.1.2行内盒子
<span/> <a/> display:inline 可以设置行高,但高会挤占空间,导致重叠。行不会挤占空间,不会重叠。
pass:行内盒子里面只能有行内盒子,不能有块级盒子
2.2 内部显示类型
2.2.1diaplay:flex 弹性布局
2.2.2diaplay:grid 网格布局
pass:display:inline-block 可以设置行高,挤占周围盒子的空间
3.box-sizing属性
3.1content-box属性.(为默认属性,更加直观)
内容区:100px
{ 内边距:10px ==> 整个盒子为100+20+2=122px
边框高度:1px 内容区为100px
3.2border-box属性
内容区:100px 盒子为100px
{ 内边距:10px ==> 内容区为100-202=78px
边框高度:1px
4.替换元素
<iframe/> <img/> <video/> 为内嵌页面,不受当前页面的css影响
京东登录页面
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>作业3.1</title>
<style>
a{
text-decoration: none;
color: #999;
font-size: 12px;
}
a:hover{
font-size: 12px;
text-decoration: underline;
}
.A{
color: #999;
font-size: 12px;
background-color: #fff8f0;
padding-top: 8px;
height: 30px;
text-align: center;
}
.B{
width: 100%;
height: 475px;
background-image: url(./4ec0b1b35efb4b4babe9614464b32e0.jpg);
background-repeat: no-repeat;
background-size: contain;
}
.C{
color: #999;
font-size: 12px;
text-align: center;
}
.B1{
width: 300px;
height: 336px;
position: relative;
top: 70px;
left: 670px;
}
.B11{
background-color: #fff8f0;
color: #FF860D;
font-size: 12px;
height: 28px;
padding: 6px 5px 6px 5px;
text-align: center;
}
.B1>div{
box-sizing: border-box;
}
</style>
</head>
<body>
<div>
<p>
<img src="https://misc.360buyimg.com/lib/img/e/logo-201305-b.png" alt="">
<img src="https://storage.jd.com/retail-mall/jdc_user_passport/pc/user/passport/1.1.1/css/i/l-icon.png" alt="">
<a href="https://wj-dongjian.jd.com/q/61a05143f2ec2b00b35e40a6" style="position: relative; left: 550px;">
<img src="https://storage.jd.com/retail-mall/jdc_user_passport/pc/user/passport/1.1.1/css/i/q-icon.png" alt="">
登入页面,改进建议
</a>
</p>
</a>
</div>
<div class="A">
依据《网络安全法》,为保障您的账户安全和正常使用,请尽快完成手机号验证! 新版
<a href="" style="color: #333;">《京东隐私政策》</a>
已上线,将更有利于保护您的个人隐私。
</div>
<div class="B">
<div class="B1">
<div class="B11">
京东不会以任何理由要求您转账,谨防诈骗
</div>
<div style="background-color: white; height: 258px; padding: 32px 16px 12px 16px;">
<div style="width: 300px; height: 18px; margin-bottom: 16px;">
<span style="color: #FA2C19; font-size: 16px;"><b>密码登录</b></span>
<span style="color: #666;"><b>短信登录</b></span>
</div>
<div>
<form action="">
<p><input type="text" style="width: 260px; height: 33px;" placeholder="账户名/手机号/邮箱"></div></p>
<input type="password" style="width: 260px; height: 33px;" placeholder="密码">
<div style="padding: 8px 0px 8px 0px; position: relative; left: 218px;"><a href="">忘记密码</a></div>
<div><button type="submit" style="background-color: #f04f0f; border: 0px; width: 268px; height: 34px; border-radius: 5px; color: white;"><b>登录</b></button></div>
</form>
</div>
</div>
<div style="background-color: #F6F6F6; height: 50px; width: 300px; position: relative; left: 670px ;">
<a href="" style="color: #595959; position: relative; top: 13px; left: 230px;">立即注册</a>
</div>
</div>
</div>
<div style="text-align: center;">
<p>
<a href="">关于我们</a> |
<a href="">联系我们</a> |
<a href="">人才招聘</a> |
<a href="">商家入驻</a> |
<a href="">广告服务</a> |
<a href="">手机京东</a> |
<a href="">友情链接</a> |
<a href="">销售联盟</a> |
<a href="">京东社区</a> |
<a href="">京东公益</a>
</p>
</div>
<div class="C">
Copyright © 2004-2024 京东JD.com 版权所有
</div>
</body>
</html>
京东shop页面
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>作业3.2</title>
<style>
.B>div{
display: inline-block;
margin-left: 110px;
position: relative;
left: 30px;
}
.B1{
font-size: 16px;
/* 使字体加粗 */
font-weight: bold;
}
.B2{
font-size: 14px;
color: #666;
}
.C{
width: 1350px;
height: 700px;
background-color: rgb(243, 243, 243);
color: #666;
}
.C>div{
background-color: #fff;
float: left;
margin: 5px;
}
.C>div>div>div>span:nth-child(2){
font-size: 20px;
font-weight: bold;
}
.C>div>div>div>span:nth-child(3){
font-size: 15px;
}
span{
color: red;
}
</style>
</head>
<body>
<div class="">
<img src="https://misc.360buyimg.com/lib/img/e/logo-201305-b.png" alt="" height="40px" style="margin-bottom: -8px;">
<input type="text" style="height: 25px; width: 400px; margin-bottom: 5px; border-color: red; position: relative; left: 150px;" placeholder="华为mate60">
<button style="padding: 0px; background-color: red; border-color: red; position: relative; left: 145px; top: 7px;">
<img src="./搜索图标.png" alt="" style="width: 55px; height: 25px;">
</button>
<div style="border: 0.5px solid #666; width: 120px; height: 30px; text-align: center; color: red;
display: inline-block; position: relative; left: 160px; top: 7px;"><img src="./购物车图标.png" alt="" height="25px">我的购物车</div>
</div>
<hr color="red">
<div class="B">
<div>
<div><div style="font-size: 16px; color: white; background-color: red ;width: 60px; border-radius: 15px; text-align: center;"><b>精选</b></div></div>
<div style="font-size: 14px; color: red;">猜你喜欢</div>
</div>
<div>
<div class="B1">智能先锋</div>
<div class="B2">大电器城</div>
</div>
<div>
<div class="B1">居家优品</div>
<div class="B2">品质生活</div>
</div>
<div>
<div class="B1">超市百货</div>
<div class="B2">百货生鲜</div>
</div>
<div>
<div class="B1">时尚达人</div>
<div class="B2">美妆穿搭</div>
</div>
<div>
<div class="B1">进口好物</div>
<div class="B2">京东国际</div>
</div>
</div>
<div class="C">
<div>
<div>
<img src="./商品展示图片.png" alt="" width="230px" height="230px">
</div>
<div><p class="more2_info_name">全网荣燿 M60Pro智能手机 16+1TB <br>新款骁龙全网通5G网络长...</p>
</div>
<div>
<div>
<span>¥</span>
<span>1099.</span>
<span>00</span>
</div>
</div>
</div>
<div>
<div>
<img src="./商品展示图片.png" alt="" width="230px" height="230px">
</div>
<div><p class="more2_info_name">全网荣燿 M60Pro智能手机 16+1TB <br>新款骁龙全网通5G网络长...</p>
</div>
<div>
<div>
<span>¥</span>
<span>1099.</span>
<span>00</span>
</div>
</div>
</div>
<div>
<div>
<img src="./商品展示图片.png" alt="" width="230px" height="230px">
</div>
<div><p class="more2_info_name">全网荣燿 M60Pro智能手机 16+1TB <br>新款骁龙全网通5G网络长...</p>
</div>
<div>
<div>
<span>¥</span>
<span>1099.</span>
<span>00</span>
</div>
</div>
</div>
<div>
<div>
<img src="./商品展示图片.png" alt="" width="230px" height="230px">
</div>
<div><p class="more2_info_name">全网荣燿 M60Pro智能手机 16+1TB <br>新款骁龙全网通5G网络长...</p>
</div>
<div>
<div>
<span>¥</span>
<span>1099.</span>
<span>00</span>
</div>
</div>
</div>
<div>
<div>
<img src="./商品展示图片.png" alt="" width="230px" height="230px">
</div>
<div><p class="more2_info_name">全网荣燿 M60Pro智能手机 16+1TB <br>新款骁龙全网通5G网络长...</p>
</div>
<div>
<div>
<span>¥</span>
<span>1099.</span>
<span>00</span>
</div>
</div>
</div>
<div>
<div>
<img src="./商品展示图片.png" alt="" width="230px" height="230px">
</div>
<div><p class="more2_info_name">全网荣燿 M60Pro智能手机 16+1TB <br>新款骁龙全网通5G网络长...</p>
</div>
<div>
<div>
<span>¥</span>
<span>1099.</span>
<span>00</span>
</div>
</div>
</div>
<div>
<div>
<img src="./商品展示图片.png" alt="" width="230px" height="230px">
</div>
<div><p class="more2_info_name">全网荣燿 M60Pro智能手机 16+1TB <br>新款骁龙全网通5G网络长...</p>
</div>
<div>
<div>
<span>¥</span>
<span>1099.</span>
<span>00</span>
</div>
</div>
</div>
<div>
<div>
<img src="./商品展示图片.png" alt="" width="230px" height="230px">
</div>
<div><p class="more2_info_name">全网荣燿 M60Pro智能手机 16+1TB <br>新款骁龙全网通5G网络长...</p>
</div>
<div>
<div>
<span>¥</span>
<span>1099.</span>
<span>00</span>
</div>
</div>
</div>
<div>
<div>
<img src="./商品展示图片.png" alt="" width="230px" height="230px">
</div>
<div><p class="more2_info_name">全网荣燿 M60Pro智能手机 16+1TB <br>新款骁龙全网通5G网络长...</p>
</div>
<div>
<div>
<span>¥</span>
<span>1099.</span>
<span>00</span>
</div>
</div>
</div>
<div>
<div>
<img src="./商品展示图片.png" alt="" width="230px" height="230px">
</div>
<div><p class="more2_info_name">全网荣燿 M60Pro智能手机 16+1TB <br>新款骁龙全网通5G网络长...</p>
</div>
<div>
<div>
<span>¥</span>
<span>1099.</span>
<span>00</span>
</div>
</div>
</div>
</div>
</body>
</html>
京东购物车页面
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>作业3.3</title>
<style>
.A{
background-color: #E3E4E5;
height: 30px;
}
.A>div{
display: inline-block;
color: #999;
font-size: 12px;
margin-top: 5px;
}
.A>div:nth-child(2)~div{
margin-left: 20px;
}
.C>div{
display: inline-block;
}
.D{
height: 40px;
background-color: rgb(243, 243, 243);
}
.D>div{
margin-top: 6px;
display: inline-block;
font-size: 12px;
}
.E1{
width: 1000px;
height: 120px;
border:1.5px solid rgb(243, 243, 243);
border-top:3px solid #6c6a6af5;
}
.E1>div{
display: inline-block;
font-size: 12px;
}
.E1>div:nth-child(1)~div{
position: relative;
bottom: 45px;
}
a{
color: #666666;
/* 去除下划线 */
text-decoration: none;
}
</style>
</head>
<body>
<div class="A">
<div style="width: 75px;">
京东首页
</div>
<div style="width: 200px;">
湖南
</div>
<div>
用户名:泽姜
<select name="" id="" style="border: 0px; background-color: #E3E4E5;">
</select>
</div>
<div>我的订单</div>
<div>我的京东
<select name="" id="" style="border: 0px; background-color: #E3E4E5;">
</select>
</div>
<div>企业采购</div>
<div>客户服务
<select name="" id="" style="border: 0px; background-color: #E3E4E5;">
</select>
</div>
<div>网站导航
<select name="" id="" style="border: 0px; background-color: #E3E4E5;">
</select>
</div>
<div>手机京东</div>
<div>网站无障碍</div>
</div><br>
<div>
<img src="https://misc.360buyimg.com/jdf/1.0.0/unit/global-header/5.0.0/i/jdlogo-201708-@2x.png" alt="" width="134px" height="42px">
<input type="text" style="border-color: red; width: 270px; height: 24px; position: relative; left: 538px;">
<button type="button" style="background-color: red; color: white; border-color: red; height: 30px; position: relative; left: 533px;"><b>搜索</b></button>
</div>
<br>
<div class="C">
<div>
<span style="font-size: 16px; color: red;"><b>全部商品</b></span>
<span style="font-size: 14px; color: red;"><b>3</b></span>
</div>
<div>
<span style="font-size: 12px; position: relative; left: 660px;">配送至:</span>
<select name="" id="" style="position: relative; left: 660px;">
<option value="">湖南长沙市望城区丁字湾街道</option>
</select>
</div>
</div>
<br>
<div class="D">
<div style="width: 130px;"><input type="checkbox">全选</div>
<div style="width: 420px;">商品</div>
<div style="width: 120px;">单价</div>
<div style="width: 130px;">数量</div>
<div style="width: 85px;">小计</div>
<div>操作</div>
</div>
<div class="E">
<div>
<input type="checkbox"> <b style="font-size: 12px; color: #666;">小米京东自营旗舰店</b>
<img src="./天猫LOGO.png" alt="">
</div>
<div class="E1">
<div style="position: relative; padding-top: 15px;">
<input type="checkbox" style="position: relative; bottom: 60px;">
<img src="./第2个手机.png" alt="">
</div>
<div>Redmi K70 Pro 第三代骁龙® 8 小米<br>澎湃OS 12GB+256GB 晴雪 AI手机</div>
<div style="position: relative; left: 200px;">
<span>¥2999.00</span>
<div>
<select name="" id="" style="border-color: red; color: red;">
<option value="">促销</option>
</select>
</div>
</div>
<div style="position: relative; left: 250px;">
<button id="reduce">-</button>
<input type="number" id="count" value="1" style="width: 46px;">
<button id="add">+</button>
<div style="text-align: center; color: #AAAAAA;">有货</div>
</div>
<div style="position: relative; left: 300px;"><strong>¥2999.00</strong></div>
<div style="position: relative; left: 350px;">
<a href="">删除</a><br>
<a href="">移入关注</a>
</div>
</div>
</div><br>
<div class="E">
<div>
<input type="checkbox"> <b style="font-size: 12px; color: #666;">优百汇手机店</b>
<img src="./天猫LOGO.png" alt="">
</div>
<div class="E1">
<div style="position: relative; padding-top: 15px;">
<input type="checkbox" style="position: relative; bottom: 60px;">
<img src="./第一个手机.png" alt="">
</div>
<div>鼎桥【准新机】鼎桥M40 5G手机<br>全网通 旗舰性能 6400万超感知影像</div>
<div style="position: relative; left: 200px;">
<span>¥1399.00</span>
<div>
<select name="" id="" style="border-color: red; color: red;">
<option value="">促销</option>
</select>
</div>
</div>
<div style="position: relative; left: 250px;">
<button id="reduce">-</button>
<input type="number" id="count" value="1" style="width: 46px;">
<button id="add">+</button>
<div style="text-align: center; color: #AAAAAA;">有货</div>
</div>
<div style="position: relative; left: 300px;"><strong>¥1399.00</strong></div>
<div style="position: relative; left: 350px;">
<a href="">删除</a><br>
<a href="">移入关注</a>
</div>
</div><br>
</div>
<div class="E">
<div>
<input type="checkbox"> <b style="font-size: 12px; color: #666;">京喜</b>
<img src="./天猫LOGO.png" alt="">
</div>
<div class="E1">
<div style="position: relative; padding-top: 15px;">
<input type="checkbox" style="position: relative; bottom: 60px;">
<img src="./第3个手机.png" alt="">
</div>
<div>华为智选鼎桥 TD Tech M40 5G手机<br>全网通 旗舰性能 6400万超感知影像</div>
<div style="position: relative; left: 200px;">
<span>¥2699.00</span>
<div>
<select name="" id="" style="border-color: red; color: red;">
<option value="">促销</option>
</select>
</div>
</div>
<div style="position: relative; left: 250px;">
<button id="reduce">-</button>
<input type="number" id="count" value="1" style="width: 46px;">
<button id="add">+</button>
<div style="text-align: center; color: #AAAAAA;">有货</div>
</div>
<div style="position: relative; left: 300px;"><strong>¥2699.00</strong></div>
<div style="position: relative; left: 350px;">
<a href="">删除</a><br>
<a href="">移入关注</a>
</div>
</div>
</div>
</body>
</html>