html卡片式轮播图带字,卡片式轮播

// import { ce } from 'migu-sdk';

export default {

name: 'zt',

data() {

return {

activityId: 'MAC_ZP_KF_MGHZJRQJXPX2019',

stage: '', // 当前活动状态

voteInfo: '', //当前所有票数列表

loading: true,

initCenterIndez: 3, // 初始化中间的index(img数组中)

currentIndex: 3, //当前中间imgs数组中index

centerInfo: '', // 当前中间信息

startX: '',

endX: '',

imgs: [

{

name: '巴耶克',

imgSrc:

'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1578753283849&di=926ab993242f5124613b7cb61134ff75&imgtype=0&src=http%3A%2F%2Fi0.hdslb.com%2Fbfs%2Farticle%2F82c9e6899e7f33bf867f207e871d61e24f473834.jpg',

index: 0

},

{

name: '马拉卡',

imgSrc:

'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1579348146&di=5548595a45061454b4b5491f65a74a0a&imgtype=jpg&er=1&src=http%3A%2F%2Fimg23.aspzz.cn%2Fuploads%2Fallimg%2Fc190116%2F154KD32553610-1044U.jpg',

index: 1

},

{

name: '艾吉奥',

imgSrc:

'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1579348251&di=7ca30312f94789c03154db45b176b599&imgtype=jpg&er=1&src=http%3A%2F%2Fi0.hdslb.com%2Fbfs%2Farticle%2Fff1a45aeb6126ba1d0bd6c9e75d192ec83b9fb1a.jpg',

index: 2

},

{

name: '巴耶克白色海报',

imgSrc:

'https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1259084891,2660179829&fm=26&gp=0.jpg',

index: 3

},

{

name: '巴耶克沙漠',

imgSrc:

'https://tim

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
你可以使用 HTML、CSS 和 JavaScript 来创建有文卡片。下面是一个简单的示例代码: ```html <!DOCTYPE html> <html> <head> <title>卡片</title> <style> .carousel { display: flex; overflow: hidden; } .carousel-item { flex: 0 0 300px; margin: 0 10px; border: 1px solid #ccc; border-radius: 5px; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3); text-align: center; padding: 20px; } </style> </head> <body> <div class="carousel"> <div class="carousel-item"> <h3>卡片1</h3> <p>这是卡片1的内容</p> </div> <div class="carousel-item"> <h3>卡片2</h3> <p>这是卡片2的内容</p> </div> <div class="carousel-item"> <h3>卡片3</h3> <p>这是卡片3的内容</p> </div> </div> <script> const carousel = document.querySelector('.carousel'); const carouselItems = document.querySelectorAll('.carousel-item'); let currentIndex = 0; function showItem(index) { carouselItems.forEach(item => { item.style.display = 'none'; }); carouselItems[index].style.display = 'block'; } function nextItem() { currentIndex = (currentIndex + 1) % carouselItems.length; showItem(currentIndex); } function previousItem() { currentIndex = (currentIndex - 1 + carouselItems.length) % carouselItems.length; showItem(currentIndex); } showItem(currentIndex); setInterval(nextItem, 3000); // 每3秒切换一次卡片 </script> </body> </html> ``` 在上述代码中,我们通过使用 flexbox 布局来创建了一个具有卡片的轮容器。每个轮项都是一个具有标题和内容的 `<div>` 元素,并且通过设置 `display` 属性来控制显示和隐藏。JavaScript 部分则实现了自动切换和手动切换的功能。 你可以根据需要自定义样和添加更多的轮项。希望这个示例能帮到你!

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值