RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / 问题 / 1296836
Accepted
Denis
Denis
Asked:2022-06-19 04:34:09 +0000 UTC2022-06-19 04:34:09 +0000 UTC 2022-06-19 04:34:09 +0000 UTC

如何制作带凹槽的条带?

  • 772

这是一个布局

在此处输入图像描述

.loader {
  height: 14px;
  overflow: hidden;
  position: relative;
  margin: 1px 0 0 0;
  border: 1px solid #eeedfd;
  background: #eeedfd;
  border-radius: 7px;
  -webkit-border-radius: 7px;
}

.loader_line {
  border-radius: 7px;
  -webkit-border-radius: 7px;
  height: 100%;
  width: 100%;
  position: absolute;
  top: 0;
  right: 0;
  background: linear-gradient(134.45deg, #7065F8 0%, #9B93FC 100%);
  background: -webkit-linear-gradient(134.45deg, #7065F8 0%, #9B93FC 100%);
}
<div class="loader">
  <div class="loader_line" style="right:calc(100% - 85% )"></div>
</div>

也就是说,有灰色背景和蓝色,但没有半透明的侧槽口?如何制作它们?

html
  • 2 2 个回答
  • 10 Views

2 个回答

  • Voted
  1. Leviathan_ZC
    2022-06-19T04:53:23Z2022-06-19T04:53:23Z

    我可以建议:

    loading-container 类块只指定加载条的位置和中心。

    <div class="loading-container">
        <div class="loading-bar">
            <div class="amount green" style="width: 40%;"> <!-- The width (and colour in class) -->
                <div class="loaded">
                    40% <!-- Loaded amount -->
                </div>
                <div class="lines"></div> <!-- The lines! -->
            </div>
        </div>
    </div>
    

    首先,让我们为loading-container类块设置样式。只需几个属性即可使加载栏居中。

    .loading-container {
        width: 600px;
        height: 300px;
        padding: 50px;
        margin: 0px auto;
        border-radius: 10px;
        background: rgba(255,255,255,0.6);
        border: 1px solid #eee;
    }
    .loading-container .loading-bar {
        margin-bottom: 40px;
    }
    

    之后,让我们设置loading-bar和amount类块的样式。loading-bar类块将是固定宽度,而数量类块 的大小将是父块的百分比。然后,您可以更改 数量类块的宽度以适应加载步骤。

    .loading-bar {
        width: 500px;
        margin: 0px auto;
        height: 61px;
        border-radius: 5px;
        background-color: #282f32;
        padding: 4px 5px;
        box-shadow: inset 3px 0px 10px rgba(0,0,0,0.1);
    }
    .amount {
        /* we haven't included the colour yet, we'll get to that later. */
        height: 60px;
        border-radius: 5px;
        white-space: nowrap;
        overflow: hidden;
        margin-top: -9px;
    }
    

    接下来,我们来看看定义背景的lines类。最有趣的是它使用SVG元素作为背景。 完成CSS样式后,我们将创建SVG文件。我们还将为这个类设置所有动画,稍后会讨论。如果浏览器不支持动画,加载栏将是静态的,这还不错。

    .lines {
        /* the lines overflow the container. This creates a continuous flow of the background */
        width: 200%;
        /* We use a SVG file as the background */
        background: url('lines.svg') repeat-x;
        height: 120%;
        text-align: center;
        margin-top: -35px;
        /* Any overflow is hidden */
        overflow: hidden;
        border-radius: 50px;
        /* Implement the animations, we'll get to that later */
        -webkit-animation: moveBars 1s linear infinite;
        -moz-animation: moveBars 1s linear infinite;
        -ms-animation: moveBars 1s linear infinite;
        -o-animation: moveBars 1s linear infinite;
        animation: moveBars 1s linear infinite;
        font-weight: bold;
        color: #fff;
        color: 1px;
        font-size: 18px;
        text-shadow: 0px 0px 10px rgba(0,0,0,0.3);
    }
    

    创建以下类只是为了 设置加载栏顶部的文本样式。

    在那之后,我们终于转向鲜花。只需添加您想要的任何块阴影和背景颜色。

    .loaded {
        text-align: center;
        font-family: Helvetica, sans-serif;
        font-weight: bold;
        position: relative;
        top: 9px;
        font-size: 30px;
        text-shadow: 0px 0px 10px rgba(0,0,0,0.2);
        color: #fff;
        z-index: 9999;
    }
    
    .green {
        background-color: #8ac320;
        box-shadow: inset 0px 4px 40px rgba(255,255,255,0.2), 0 10px 10px -5px #79aa1e , 0 7px 0 #628c14;
    }
    
    .blue {
        background-color: #20b9c3;
        box-shadow: inset 0px 4px 40px rgba(255,255,255,0.2), 0 10px 10px -5px #1e8aaa, 0 7px 0 #13768c;
    }
    .red {
        background-color: #dc6565;
        box-shadow: inset 0px 4px 40px rgba(255,255,255,0.2), 0 10px 10px -5px #d23333, 0 7px 0 #8c1212;
    }
    

    最后,动画。我们需要做的就是将线条类块向左移动 180 像素。因此,在100 % 时,即在动画结束时,将左边距更改为-180px。由于供应商前缀,动画通常在CSS文件中占用大量空间,但这里所有内容都适合5行:

    /* ANIMATIONS */
    @keyframes moveBars { 100% { margin-left: -180px; } }
    @-webkit-keyframes moveBars { 100% { margin-left: -180px; } }
    @-moz-keyframes moveBars { 100% { margin-left: -180px; } }
    @-ms-keyframes moveBars { 100% { margin-left: -180px; } }
    @-o-keyframes moveBars { 100% { margin-left: -180px; } }
    

    这就是CSS代码。

    现在让我们转到由SVG文件组成的背景。

    <svg xmlns="http://www.w3.org/2000/svg" width="180" height="180">
      <title>Diagonal Lines</title>
      <desc>Some diagonal lines for use in the loading bar.</desc>
     <polygon fill="white" opacity="0.2" points="90,0 180,0 90,180 0,180" />
    </svg>
    

    这个条目是什么意思?第一行类似于HTML文档的文档类型。之后,我们为SVG命名和描述,以获得正确且易于理解的结构。然后我们画一个多边形。它只是一个0.2 opacity 的白色形状。然后我们设置点。这些是文档中我们要放置多边形的坐标。每组点由一个空格分隔。毕竟,您所要做的就是将此代码放入名为lines.svg的文件中,并将其保存在与您的CSS文件 相同的类别中。

    最后结果

    资源

    • 2
  2. Best Answer
    Pilaton
    2022-06-19T06:59:31Z2022-06-19T06:59:31Z

    :root {
      --color-one: #8B86F1;
      --color-two: #7B76F1;
    }
    
    .bg {
      background-color: #eee;
      width: 400px;
      height: 15px;
      margin: 0 auto;
      border-radius: 10px;
      overflow: hidden;
    }
    
    .bar {
      background: linear-gradient( 225deg, var(--color-one) 25%, var(--color-two) 25%, var(--color-two) 50%, var(--color-one) 50%, var(--color-one) 75%, #008283 75%);
      width: 80%;
      height: 100%;
      background-size: 25px 25px;
      border-radius: 10px;
    }
    <div class="bg">
      <div class="bar"></div>
    </div>

    • 2

相关问题

  • 具有非均匀背景的块内的渐变边框

  • 离开页脚

  • 如何将三个字段的数据收集到一封电子邮件中?

  • Html 元素刚从父元素中出来

  • 如何在css中制作这个背景?

  • 如何制作带有斜条纹的背景?

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    表格填充不起作用

    • 2 个回答
  • Marko Smith

    提示 50/50,有两个,其中一个是正确的

    • 1 个回答
  • Marko Smith

    在 PyQt5 中停止进程

    • 1 个回答
  • Marko Smith

    我的脚本不工作

    • 1 个回答
  • Marko Smith

    在文本文件中写入和读取列表

    • 2 个回答
  • Marko Smith

    如何像屏幕截图中那样并排排列这些块?

    • 1 个回答
  • Marko Smith

    确定文本文件中每一行的字符数

    • 2 个回答
  • Marko Smith

    将接口对象传递给 JAVA 构造函数

    • 1 个回答
  • Marko Smith

    正确更新数据库中的数据

    • 1 个回答
  • Marko Smith

    Python解析不是css

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5