PHP怎么设置字体走马灯效果,微信小程序怎么设置背景颜色渐变以及字体走马灯效果(高考倒计时)...

效果图:

66803968f20ad9c73ad283ad8fe46258.png 图1

a77cfa89d3b4deb6b462e7325feae5ef.png 图2

一、背景颜色渐变

1、wxml文件

c4a90236463fb8537e6b1981580da6ee.png

高考广播:距2020高考仅剩{{countdown}}天

2、wxss文件

c633f52794842236a693b7cb5096a673.png

.Broadcast{

position:relative;

right: 20rpx;

top: 8rpx;

float: right;

width:400rpx;

height:40rpx;

overflow: hidden;

/* 颜色渐变 */

background: -webkit-linear-gradient(left,rgba(0,0,0,0.01),rgba(0,0,0,0.2),rgba(0,0,0,0.01));

border-radius:13px;

z-index: 10;

}

二、字体走马灯

1、wxml文件

7957506175869d659af205bde2f45062.png

高考广播:距2020高考仅剩{{countdown}}天

2、wxss文件

4a790bb39bb53f287e5c393f3c64315c.png 图1

3e571f5fd53e25b0bc68cd992ef20991.png 图2

.Broadcast_text{

position: absolute;

text-align: center;

left: 50%;

top: 25%;

transform: translate(-50%,-25%);

width:400rpx;

height:28rpx;

font-size:11px;

font-family:Microsoft YaHei;

font-weight:400;

opacity:1;

color:rgba(255,255,255,1);

text-shadow:0px 2px 4px rgba(0, 0, 0, 0.45);

z-index: 20;

}

/* 高考倒计时轮播 */

@keyframes around {

from {

margin-left: 100%;

}

to {

/* var接受传入的变量 */

margin-left: var(--marqueeWidth--);

}

}

.Broadcast_text{

display: inline-block;

white-space: nowrap;

animation-name: around;

animation-duration: 10s; /*过渡时间*/

animation-iteration-count: infinite;

animation-timing-function:linear;

}

3、js文件

2c65c298017486cc5b78fc3bd4870bc0.png 图1

a88e3b55d2f5ebe78745545a82cde6db.png 图2

getSize() {

let that = this;

wx.getSystemInfo({

success: function (res) {

console.log(res.windowHeight);

that.setData({

windowHeight: res.windowHeight

})

},

})

},

/**

* 生命周期函数--监听页面加载

*/

onLoad: function (options) {

this.getSize();

var that = this

that.countDown();

},

//倒计时

countDown() {

var that = this

var starttime = '2019/09/08 00:00:00'

var start = new Date(starttime.replace(/-/g, "/")).getTime()

var endTime = start + 274 * 60 * 24 * 60000

var date = new Date(); //现在时间

var now = date.getTime(); //现在时间戳

var allTime = endTime - now

var d, h, m, s;

if (allTime > 0) {

// m = Math.floor(allTime / 1000 / 60 % 60);

// s = Math.floor(allTime / 1000 % 60);

d = Math.floor(allTime / 1000 / 60 / 60 / 24);

// h = Math.floor(allTime / 1000 / 60 / 60 % 24);

that.setData({

countdown: d,

})

setTimeout(that.countDown, 100);

} else {

console.log('高考即将开始!')

that.setData({

countdown: '00'

})

}

},

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值