CSS外边距margin,小米广告、品优购案例165

盒子外边距margin
使用方法与内边距padding类似
在这里插入图片描述
水平居中方法盒子
在这里插入图片描述
在这里插入图片描述
行内元素和行内块元素居中方法
在这里插入图片描述
居中综合案例

    <style>
      .header{
        width: 200px;
        height: 200px;
        background-color:pink;
        margin: 20px auto;
        text-align: center;
      }
    </style>
  </head>
  <body>
    <div class="header">
      <span>文字</span>
    </div>
  </body>

嵌套块元素塌陷问题
在这里插入图片描述
在这里插入图片描述

        border: 1px solid transparent;
        padding: 2px;
        overflow: hidden;

清除内外边距

      *{
        margin: 0;
        padding: 0;
      }

使用PS的基础操作

在这里插入图片描述

小米广告小案例

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    *{
      margin: 0;
      padding: 0;
    }
    body{
      background-color: #ededed;
    }
    .box1{
      width: 234px;
      height: 300px;
      margin: 100px auto;
      background-color:#fff;
    }
    .box1 .quwendai{
      width: 160px;
      height: 160px;
      padding: 0 37px;
      margin-top: 20px;
    }
    .box1 .name{
      height: 25px;
      padding: 0 55px;
      margin-top: 5px;
      text-align: center;
      font-size: 14px;
    }
    .box1 .introduce{
      font-size: 12px;
      color: #c2c2c2;
      padding: 0 80px;
      margin-top: 2px;
    }
    .box1 .price {
      font-size: 14px;
      padding: 0 75px;
      margin-top: 15px;
    }
    .box1 .price .cupr{
      color: #ff6e0b;
    }
    .box1 .price .bfpr{
      color: #b0b0b0;
      /* 文字下划线 */
      text-decoration:line-through;
    }
  </style>
</head>
<body>
  <div class="box1">
    <img src="垃圾袋.webp" alt="" class="quwendai">
    <p class="name">3卷装抽绳式垃圾袋</p>
    <p class="introduce">让清洁更简单</p>
    <div class="price">
      <span class="cupr">9.9</span>
      <span class="bfpr">14.9</span>
    </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>Document</title>
  <style>
    *{
      margin: 0;
      padding: 0;
    }
    .pingyougou{
      width: 250px;
      height: 200px;
      margin: 100px auto;
      border: 2px solid #cccccc;
    }
    .title{
      width: 250px;
      height: 35px;
      border-bottom: 2px dotted #cccccc;
      color: #666666;
    }
    .title .name{
      display:inline-block;
      padding: 0 112px 0 15px;
      margin: 10px;
    }
    .title .more{
      text-decoration: none;
    }
    .content {
      padding:0 0 0 20px;
      margin-top: 15px;
    }
    .contentbox li{
      list-style: none;
      margin-bottom: 12px;
    }
    .contentbox li a{
      text-decoration: none;
      color: #666666;
    }
  </style>
</head>
<body>
  <div class="pingyougou">
    <div class="title">
    <h4 class="name">品优购快报</h4>
    <a href="http://www.boyuanwl.com/#" class="more">更多</a>
  </div>
  <div class="content">
    <ur class="contentbox">
      <li class="content1">
        <a href="http://www.boyuanwl.com/#" >【特惠】爆款耳机5折秒!</a>
      </li>
      <li class="content2">      
        <a href="http://www.boyuanwl.com/#" ">【特惠】母情节,健康好礼低至5折!</a>
      </li>
      <li class="content3"> 
        <a href="http://www.boyuanwl.com/#" ">【特惠】爆款耳机5折秒!</a>
      </li>
      <li class="content4">
        <a href="http://www.boyuanwl.com/#" >【特惠】9.9元洗十张照片!</a>
      </li>
      <li class="content5">
        <a href="http://www.boyuanwl.com/#" >【特惠】长虹智能空调立省1000元!</a>
      </li>
    </ur>
  </div>
  </div>
</body>
</html>

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值