CSS背景案例,三大特性,盒子边框内边距149

1.背景图像固定

      background-attachment: fixed;

2.背景复合写法
在这里插入图片描述

      background: pink url() no-repeat fixed top;

3.背景颜色半透明
在这里插入图片描述

      background: rgba(255, 0, 0, 0.3);

五彩导航小案例

<style>
    .nav a{
      display: inline-block;
      width: 120px;
      height: 58px;
      background-color: pink;
      line-height: 50px;
      text-align: center;
      text-decoration: none;
      color: #ffffff;
    }
    .nav .bg1{
      background: url(bg1.png) no-repeat;
    }
    .nav .bg1:hover{
      background-image: url(bg2.png);
    }
    .nav .bg2{
      background: url(bg3.png) no-repeat;
    }
    .nav .bg2:hover{
      background-image: url(bg4.png);
    }
  </style>
  <body>
    <div class="nav">
      <a href="#" class="bg1">五彩导航</a>
      <a href="#" class="bg2">五彩导航</a>
    </div>
  </body>

CSS层叠性

在这里插入图片描述

CSS继承性

在这里插入图片描述在这里插入图片描述

CSS优先级

权重高的优先级高
在这里插入图片描述
注意事项
在这里插入图片描述

盒子模型

在这里插入图片描述
1.盒子边框border
在这里插入图片描述

    div{
      width: 300px;
      height: 200px;
      /* 边框宽度 */
      border-width: 4px;
      /* 边框样式 ,solid实线边框,dashed虚线边框,dotted点线边框*/
      border-style:dotted;
      /* 边框颜色 */
      border-color: pink;
    }

边框简写方法
没有顺序要求

      border: 4px solid pink;

边框分写方法

      border-top: 2px dashed red;
      border-bottom: 3px solid blue;
      border-left: 4px dotted yellow;
      border-right: 5px solid #000;

表格细线边框
在这里插入图片描述

2.盒子内边距padding
就是边框与内容之间的距离
在这里插入图片描述

      padding-top: 20px;
      padding-bottom: 20px;
      padding-left: 20px;
      padding-right: 20px;

属性值:
属性值
在这里插入图片描述

新闻导航栏案例

   <style>
      .nav {
        height: 41px;
        border-top: 3px solid #ff8500;
        border-bottom: 1px solid #edeef0;
        background-color: #fcfcfc;
        line-height: 41px;
      }
      .nav a{
        display:inline-block;
        height: 41px;
        color: #4c4c4c;
        font-size: 14px;
        text-decoration: none;
        padding: 0 20px;
      }
      .nav a:hover{
        background-color: #ff8500;
      }
    </style>
  </head>
  <body>
    <div class="nav">
      <a href="#">微博</a>
      <a href="#">新浪网</a>
      <a href="#">新浪微博</a>
      <a href="#">新浪导航网</a>
    </div>
  </body>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值