HTML+CSS小实例(进度条)

目录

效果展示:

 网页源码:

HTML模块:

CSS模块:


效果展示:

 网页源码:

HTML模块:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>技能进度条</title>
    <link rel="stylesheet" href="css/ProgressBar.css">
</head>
<body>
<div>
    <ul>
        <li class="js">JavaScript</li>
        <li class="react">React</li>
        <li class="html5">HTML5</li>
        <li class="css3">CSS3</li>
        <li class="sketch">Sketch</li>
    </ul>
</div>
</body>
</html>

CSS模块:

html, body {
    margin: 0;
    padding: 0;
    font-family: sans-serif;
}

* {
    box-sizing: border-box;
}

div {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background-color: #1e272e;
}

ul {
    width: 500px;
}

li {
    list-style: none;
    color: #d2dae2;
    font-size: 18px;
    margin: 48px 0;
    position: relative;
}

li:before, li:after {
    content: "";
    display: block;
    height: 16px;
    width: 100%;
    background-color: #1f4a59;
    position: absolute;
    bottom: -28px;
    border-radius: 6px;
}

li:before {
    box-shadow: 0 0 6px rgba(75, 207, 250, 0.2);
}

li:after {
    background-image: linear-gradient(90deg, #0fbcf9, #34e7e4);
}

li:after {
    animation: 1.2s forwards ease-in-out;
}

.js:after {
    animation-name: js;
}

.react:after {
    animation-name: react;
}

.html5:after {
    animation-name: html5;
}

.css3:after {
    animation-name: css3;
}

.sketch:after {
    animation-name: sketch;
}

@keyframes js {
    from{
        width: 0;
    }to{
         width: 90%;
     }
}
@keyframes react {
    from{
        width: 0;
    }to{
         width: 80%;
     }
}
@keyframes html5 {
    from{
        width: 0;
    }to{
         width: 70%;
     }
}
@keyframes css3 {
    from{
        width: 0;
    }to{
         width: 60%;
     }
}
@keyframes sketch {
    from{
        width: 0;
    }to{
         width: 50%;
     }
}

参考:b站up主 叫我凤凰Blanco

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要自定义微信小程序video的进度条,可以使用wx.createVideoContext()方法获取video组件实例,然后通过该实例的属性和方法来实现自定义进度条的效果。 以下是一个简单的示例代码: wxml文件部分: ```xml <video src="{{src}}" id="myVideo"></video> <view class="progress-bar" style="width: {{progress}}%;"></view> ``` js文件部分: ```javascript Page({ data: { src: '视频地址', duration: 0, // 视频总时长 currentTime: 0, // 当前播放时间 progress: 0 // 进度条进度 }, onLoad: function () { // 获取video组件实例 this.videoContext = wx.createVideoContext('myVideo', this); // 监听视频播放时间变化事件 this.videoContext.onTimeUpdate(this.handleTimeUpdate); // 获取视频总时长 this.videoContext.duration((duration) => { this.setData({ duration: duration }); }); }, handleTimeUpdate: function (e) { // 更新当前播放时间和进度条进度 this.setData({ currentTime: e.detail.currentTime, progress: e.detail.currentTime / this.data.duration * 100 }); } }); ``` css文件部分: ```css .progress-bar { height: 6px; background-color: #ccc; } ``` 在上述代码中,我们首先通过wx.createVideoContext()方法获取video组件实例,然后在onLoad()生命周期函数中监听视频播放时间变化事件,并获取视频总时长。在handleTimeUpdate()函数中,我们更新当前播放时间和进度条进度,最后在wxml文件中使用style属性来设置进度条的宽度。 需要注意的是,为了让Video组件支持进度条拖动功能,还需要在wxml文件中添加bindtouchstart、bindtouchmove和bindtouchend事件,并在js文件中添加相应的处理函数。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值