css整理二

在这里插入图片描述

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div style="width: 50px;height: 50px;background-color: black;color:white;
     position: fixed; <!--固定在页面的某个位置-->
     bottom:20px;
     right:20px;
     ">返回顶部</div>
   <div style="height: 5000px;background-color: #dddddd;"></div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .pg-header{
            height: 48px;
            background-color: black;
            color: #dddddd;
            position: fixed;
            top:0;
            left:0;
            right:0;
        }
        .pg-body{
            background-color: #dddddd;
            height: 5000px;
        }
    </style>
</head>
<body>
   <div class="pg-header" style="margin-top:2px">头部</div>
   <div class="pg-body" style="margin-top:61px;">内容</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
   <div style="position: relative;width: 500px;height: 200px;border: 1px solid red; margin:0 auto">
       <div style="position: absolute;left:0;bottom:0;width:50px;height: 50px;background-color:black;"> </div>
   </div>

   <div style="position: relative;width: 500px;height: 200px;border: 1px solid red; margin:0 auto">
        <div style="position: absolute;right:0;bottom:0;width:50px;height: 50px;background-color:black;"> </div>
   </div>
   <div style="position: relative;width: 500px;height: 200px;border: 1px solid red; margin:0 auto">
        <div style="position: absolute;left:0;top:0;width:50px;height: 50px;background-color:black;"> </div>
   </div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div style="z-index:10;
    position:fixed;
    top:50%;
    left:50%;
    margin-left: -250px;margin-top:-200px;
    background-color:white;
    height: 400px;
    width:500px;
    ">
    老夫的少女心啊
    </div>
   <div style="z-index:9; position: fixed;background-color: #dddddd;
    top:0;
    bottom:0;
    right:0;
    left:0;
    opacity:0.5; <!--设置透明度-->
    "></div>
   <div style="z-index:8;height:5000px;background-color: red;">
       adfads
   </div>
</body>
</html>

overflow

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
   <div style="height: 200px;width: 300px;overflow: auto">
       <!--overflow: hidden超出隐藏,auto出现滚动条-->
       <img src="萤火虫.jpg">
   </div>
</body>
</html>

hover

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .pg-header{
            position: fixed;
            right:0;
            left:0;
            top:0;
            height: 48px;
            background-color:#2459a2;
            line-height: 48px;
        }
        .pg-body{
            margin-top: 50px;
        }
        .w{
            width: 980px;
            margin: 0 auto;
        }
       
        .pg-header .menu:hover{
            background-color: blue;
        }
        .pg-header .menu{
            display: inline-block;
            padding: 0 10px; <!--0是上下,10是左右-->
            color: white;
        }
    </style>
</head>
<body>
   <div class="pg-header">
       <div class="w">
           <a class="logo">LOGO</a>
           <a class="menu">全部</a>
           <a class="menu">全部1</a>
           <a class="menu">全部2</a>
           <a class="menu">全部3</a>
       </div>
   </div>

   <div class="pg-body">
        <div class="w">a</div>
   </div>
</body>
</html>

background-image

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
   <div style="background-image:url('萤火虫.jpg');height:180px; background-repeat: no-repeat;">
    <!--no-repeat不重复,repeat-x水平重复,repeat-y垂直方向重复-->
   </div>
</body>
</html>

小案例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

   <div style="height: 35px;width: 400px;position: relative;">
        <input type="text" style="height: 35px;width: 370px;padding-right:30px;" />
        <span style="position:absolute;right:0;top:10px;background-image: url(萤火虫.jpg);height: 20px;width: 20px;display:inline-block;"></span>
    </div>
</body>
</html>

在这里插入图片描述

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值