当前位置: 首页 > news >正文

【CSS + ElementUI】更改 el-carousel 指示器样式且隐藏左右箭头

  1. 需求
    前三条数据以走马灯形式展现,指示器 hover 时可以切换到对应内容
    在这里插入图片描述

  2. 实现

<template><div v-loading="latestLoading"><div class="upload-first" v-show="latestThreeList.length > 0"><el-carousel indicator-position="outside" height="180px" :autoplay="autoplay"><el-carousel-item v-for="(item) in latestThreeList" :key="item.id"><div class="carousel-content" @click="handleDetail(item.id)"><div class="first-title"><span>{{ item.kind}}</span></div><div class="first-subtitle">{{ item.title }}</div><div class="first-summary">{{ item.summary }}</div><div class="first-time">{{ item.createTime | formatTimer(item.createTime) }}</div></div></el-carousel-item></el-carousel></div></div>
</template>
<script>
import { getList } from '@/api/xxx'
import { dateFormat } from '@/utils/utils'
export default {data(){return{latestLoading:false,latestThreeList: [],query:{pageNum:1,pageSize:10}}},mounted(){this.fetchData()},filters: {formatTimer(date) {return dateFormat(new Date(date),"yyyy-MM-dd")}},methods:{fetchData(){this.latestLoading = truegetList(this.query).then(res=>{this.latestThreeList = res.data.slice(0, 3)this.latestLoading = false})},handleDetail(id){// 跳转到详情页}}
}
</script>
<style lang="less"> 
.upload-first {padding-bottom: 12px;flex-direction: column;align-items: flex-start;gap: 8px;align-self: stretch;border-radius: 10px;width: 976px;height: 184px;background: rgba(4, 106, 249, 0.05);margin: 24px auto;padding: 0 16px 0 0;.carousel-content:hover {color: #023fb5;cursor: pointer;}.first-title {display: flex;justify-content: flex-start;align-items: center;span {color: #2AC91C;font-family: "Source Han Sans CN";font-size: 12px;font-style: normal;font-weight: 400;line-height: 24px;border-radius: 0px 0px 20px 0px;background: #D6FFDE;padding: 8px 12px;}}.first-subtitle {color: #333;font-family: "Source Han Sans CN";font-size: 18px;font-style: normal;font-weight: 500;line-height: 24px;padding: 16px;}.first-subtitle:hover {color: #023fb5;cursor: pointer;}.first-summary {color: #666;font-family: "Source Han Sans CN";font-size: 16px;font-style: normal;font-weight: 400;line-height: 24px;padding: 0 16px;display: -webkit-box;/*! autoprefixer: off */-webkit-box-orient: vertical;/* autoprefixer: on */-webkit-line-clamp: 2;overflow: hidden;height: 48px;}.first-time {color: #666;font-family: "Source Han Sans CN";font-size: 14px;font-style: normal;font-weight: 350;line-height: 24px;text-align: right;}}.el-carousel__arrow { // 隐藏左右箭头display: none;}.el-carousel__indicator { // 改变指示器非选中下样式.el-carousel__button {width: 10px;height: 10px;border-radius: 50%;background-color: #f0f0f0;opacity: 1 !important;}}.el-carousel__indicator.is-active button { // 改变指示器选中时的样式background-color: #023FB5 !important;border-radius: 50%;outline: none;width: 8px;height: 8px;&:active {display: contents; // 解决左右箭头和指示器点击时有黑色边框}}
</style>
  1. 问题解决
    隐藏左右箭头,用 display: none;
    鼠标点击,出现黑边框,用display: contents;
    在这里插入图片描述
    在这里插入图片描述

  2. 最终效果
    在这里插入图片描述

  3. 数据结构

[{id:1,kind:'课题成果',title:'测试股1',summary:'测试股1',createTime:'2024-01-31 14:16:41'},{id:2,kind:'政策',title:'第二十条',summary:'摘要',createTime:'2024-02-04 15:16:41'}
]
  1. 日期格式化 @/utils/utils
/*** 日期格式化*/
export function dateFormat(date, format) {format = format || "yyyy-MM-dd hh:mm:ss";if (date !== "Invalid Date") {let o = {"M+": date.getMonth() + 1, //month"d+": date.getDate(), //day"h+": date.getHours(), //hour"m+": date.getMinutes(), //minute"s+": date.getSeconds(), //second"q+": Math.floor((date.getMonth() + 3) / 3), //quarterS: date.getMilliseconds() //millisecond};if (/(y+)/.test(format))format = format.replace(RegExp.$1,(date.getFullYear() + "").substr(4 - RegExp.$1.length));for (let k in o)if (new RegExp("(" + k + ")").test(format))format = format.replace(RegExp.$1,RegExp.$1.length === 1 ?o[k] :("00" + o[k]).substr(("" + o[k]).length));return format;}return "";
}

相关文章:

  • Qt应用软件【数据篇】大小端数据转换
  • Linux进程信号处理:深入理解与应用(2​​)
  • 【Tomcat与网络6】 Tomcat是如何扩展Java线程池的?
  • Python flask 模板详解
  • 物流平台架构设计与实践
  • Node.js的安装
  • 理解React中的setState()方法
  • R语言基础学习-02 (此语言用途小众 用于数学 生物领域 基因分析)
  • 【如何快速上手Vue.js框架——详细介绍】
  • 《Lua程序设计》-- 学习9
  • Shell脚本是一种用来自动化执行一系列命令的文本文件
  • 公共用例库计划--个人版(六)典型Bug页面设计与开发
  • cesium-水平测距
  • 基于flask的个人博客项目从0到1
  • 微信小程序实现吸顶、网格、瀑布流布局
  • Apache Zeppelin在Apache Trafodion上的可视化
  • Docker入门(二) - Dockerfile
  • Java反射-动态类加载和重新加载
  • JS数组方法汇总
  • k个最大的数及变种小结
  • laravel 用artisan创建自己的模板
  • rc-form之最单纯情况
  • 彻底搞懂浏览器Event-loop
  • 从零开始的无人驾驶 1
  • 免费小说阅读小程序
  • 如何利用MongoDB打造TOP榜小程序
  • 设计模式走一遍---观察者模式
  • 十年未变!安全,谁之责?(下)
  • 新书推荐|Windows黑客编程技术详解
  • #Linux杂记--将Python3的源码编译为.so文件方法与Linux环境下的交叉编译方法
  • (Mac上)使用Python进行matplotlib 画图时,中文显示不出来
  • (多级缓存)多级缓存
  • (附源码)springboot金融新闻信息服务系统 毕业设计651450
  • (附源码)计算机毕业设计ssm电影分享网站
  • (附源码)计算机毕业设计SSM疫情居家隔离服务系统
  • (原)记一次CentOS7 磁盘空间大小异常的解决过程
  • (转)C#调用WebService 基础
  • .NET Core WebAPI中封装Swagger配置
  • .Net Memory Profiler的使用举例
  • .Net Winform开发笔记(一)
  • .NET 同步与异步 之 原子操作和自旋锁(Interlocked、SpinLock)(九)
  • /usr/lib/mysql/plugin权限_给数据库增加密码策略遇到的权限问题
  • []使用 Tortoise SVN 创建 Externals 外部引用目录
  • [20190401]关于semtimedop函数调用.txt
  • [2021ICPC济南 L] Strange Series (Bell 数 多项式exp)
  • [AS3]URLLoader+URLRequest+JPGEncoder实现BitmapData图片数据保存
  • [BZOJ 3531][Sdoi2014]旅行(树链剖分+线段树)
  • [C/C++]数据结构 深入挖掘环形链表问题
  • [C/C++]数据结构----顺序表的实现(增删查改)
  • [C++]priority_queue的介绍及模拟实现
  • [ES-5.6.12] x-pack ssl
  • [FFmpeg学习]从视频中获取图片
  • [IE9] IE9 RC版下载链接
  • [JavaScript]如何讓IE9, IE8, IE7, IE6關閉視窗時不彈出對話訊息
  • [Linux基础开发工具---vim]关于vim的介绍、vim如何配置及vim的基本操作方法