• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

盒子阴影(box-shadow)和文字阴影text-shadow

武飞扬头像
一条程序○
帮助1

一、盒子阴影:

书写语法:box-shadow: inset   h-shadow   v-shadow   blur-radius   color;
    inset 阴影类型为内阴影
    outset 阴影类型为外阴影  (不添加时默认为外阴影,但是添加后反而会使得阴影无效,所以如果要想实现外阴影可以不加)
    h-shadow----- 阴影的水平位移量 允许为负值
    v-shadow----- 阴影垂直位移量 允许为负值
    blur-radius-----阴影模糊半径 即阴影向外模糊的模糊范围  值越大越模糊 
    color----- 阴影颜色,定义绘制阴影时所使用的颜色  

例如:(配合hover效果实现)

  1.  
    <!DOCTYPE html>
  2.  
    <html lang="en">
  3.  
    <head>
  4.  
    <meta charset="UTF-8">
  5.  
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.  
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.  
    <title>Document</title>
  8.  
    <style>
  9.  
    body{
  10.  
    background-color: #007aff;
  11.  
    display: flex;
  12.  
    justify-content: center;
  13.  
    align-items: center;
  14.  
    min-height: 100vh;
  15.  
    }
  16.  
    .wrap{
  17.  
    position: relative;
  18.  
    width: 300px;
  19.  
    height: 400px;
  20.  
    border-radius: 40px;
  21.  
    box-shadow: 5px 5px 15px rgba(0, 0, 0, 0.5) inset,-5px -5px 15px rgba(255, 255, 255, 0.5) inset,5px 5px 15px rgba(0, 0, 0, 0.5) inset,5px 5px 15px rgba(0, 0, 0, 0.5) inset;
  22.  
    }
  23.  
    .wrap::after{
  24.  
    display: block;
  25.  
    content: "";
  26.  
    clear: both;
  27.  
    position: absolute;
  28.  
    background-color: white;
  29.  
    border-radius: 35px;
  30.  
    inset: 5px;
  31.  
    transition: 1s;
  32.  
    }
  33.  
    .wrap:hover::after{
  34.  
    cursor: pointer;
  35.  
    transform: translate(40px,-40px);
  36.  
    box-shadow: -30px 30px 50px rgba(0, 0, 0, 0.5);
  37.  
    }
  38.  
    </style>
  39.  
    </head>
  40.  
    <body>
  41.  
    <div class="wrap"></div>
  42.  
    </body>
  43.  
    </html>
学新通

实现效果:

盒子阴影 hover效果

 
二、文字阴影:

书写语法:text-shadow: h-shadow v-shadow blur color; 
h-shadow -----

水平阴影的位置,允许负值 
v-shadow -----垂直阴影的位置,允许负值 
blur-----模糊的距离 (如果设置的是0,那么将和正常的文字清晰度一样)
color------阴影的颜色

例如:

  1.  
    <!DOCTYPE html>
  2.  
    <html lang="en">
  3.  
    <head>
  4.  
    <meta charset="UTF-8">
  5.  
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6.  
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.  
    <title>Document</title>
  8.  
    <style>
  9.  
    .wrap{
  10.  
    font-size: 100px;
  11.  
    text-align: center;
  12.  
    background-color: #007aff;
  13.  
    }
  14.  
    .wrap::after{
  15.  
    display: block;
  16.  
    content: "哒哒哒";
  17.  
    clear: both;
  18.  
    color: white;
  19.  
    text-shadow:
  20.  
    0px -1px 0px #c0c0c0,
  21.  
    0px -2px 0px #b0b0b0,
  22.  
    0px -3px 0px #a0a0a0,
  23.  
    0px -4px 0px #909090,
  24.  
    0px -5px 0px #c0c0c0,
  25.  
    0px -6px 0px #b0b0b0,
  26.  
    0px -7px 0px #a0a0a0,
  27.  
    0px -8px 0px #909090,
  28.  
    0px -9px 10px rgba(0, 0, 0, 0.6);
  29.  
    }
  30.  
    </style>
  31.  
    </head>
  32.  
    <body>
  33.  
    <div class="wrap"></div>
  34.  
    </body>
  35.  
    </html>
学新通

实现的效果为: 

学新通

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhfiaebg
系列文章
更多 icon
同类精品
更多 icon
继续加载