css小技巧 linear-gradient

设计图:

现在的要求是不准用图片,好吧,那就用代码简单实现下。

方式1:svg
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
  <rect x="-30" y="1" rx="8" ry="8" width="64" height="34" 
style="fill:#ffffff;stroke:black;stroke-width:1;" />
</svg>

效果:

太丑,不行

方式2:背景渐变,中间套一层白色背景,保留边框1px
 <div class="box">
    <div class="btn-box">报表查询</div>
 </div>


  .box {
    display: inline-block;
    padding: 1px;
    background: linear-gradient(90deg,#fff,#ccc);
    border-radius: 8px;
    .btn-box{
      padding: 10px 20px;
      display: inline-block;
      background: #ffffff;
      border-radius: 8px;
     }
   }

效果:

效果一般,勉强能用。

但是,UI改设计了,白色底不好看,改透明了,这种背景色渐变的就不能用了。

方式3:border边框渐变
<div class="box">
  <div class="btn-box">报表查询</div>
</div>

  .box {
    text-align: center;
    border-radius: 8px;
    border-right: 1px solid #495B6A;
    box-sizing: border-box;

    .btn-box{
      width: 94px;
      height: 34px;
      display: flex;
      justify-content: center;
      align-items: center;
      border-top: 1px solid;
      border-bottom: 1px solid;
      border-image: linear-gradient(90deg, transparent 60%, #495B6A 90%, transparent 97%) 1;
    }
  }

效果:

就这个了!

相关推荐

  1. 32. 批量梯度下降法(Mini-batch Gradient Descent)

    2023-12-08 15:18:01       28 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-08 15:18:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-08 15:18:01       101 阅读
  3. 在Django里面运行非项目文件

    2023-12-08 15:18:01       82 阅读
  4. Python语言-面向对象

    2023-12-08 15:18:01       91 阅读

热门阅读

  1. LeeCode每日刷题12.8

    2023-12-08 15:18:01       51 阅读
  2. 附录1、vuepress中的Markdown语法

    2023-12-08 15:18:01       63 阅读
  3. 利用 Python 进行数据分析实验(三)

    2023-12-08 15:18:01       53 阅读
  4. 利用 Python 进行数据分析实验(五)

    2023-12-08 15:18:01       57 阅读
  5. docker网络

    2023-12-08 15:18:01       46 阅读
  6. VBA 数组写入ACCESS

    2023-12-08 15:18:01       62 阅读
  7. 数据结构的存储方式

    2023-12-08 15:18:01       55 阅读