点击div实现选中效果
先上一份效果图。原来的checked多选框还是存在的,我只不过隐藏了,让他的整个div的范围都是可以点击的,右上角三个点是可以删除当前元素,左下角的播放按钮可以点击播放语音,主要是利用z-index把层次提高一点,就可以了,frame是选中后的意思,动态判断一下,如果checked等于true了,就把这个类加上。

下面是一个div的结构
<div class="items flex">
<div
:class="{item ,'frame':item.checked}"
v-for="(item, index) in list"
:key="index"
>
<a-checkbox
v-model:checked="item.checked"
class="selectVoice"
@change.stop="selectOneChange(item, $event)"
v-show="item.checked"
></a-checkbox>
<a-tooltip placement="right" class="a_tool">
<template #title>
<div class="delete flex">
<div class="btn" @click="deleteOne(item)">删除</div>
</div>
</template>
<span>•••</span>
</a-tooltip>
<div
class="img"
:style="{'background-image': 'url(' + item.head_img_url +')'}">
<div class="time">
{{item.voice_collect_time}}
</div>
<div class="span">
<span>{{item.username}}</span>
</div>
</div>
<a-tooltip placement="top" :overlayClassName="{'tooltip':item.voice_content.length > 100}" :arrowPointAtCenter="true">
<template #title v-if="item.voice_content">
<span>{{item.voice_content}}</span>
</template>
<div class="title">
<img @click.stop="playVoice(item.voice_url,item.voice_duration,item)" src="@/assets/materialManagement/Frame.png" alt="">
<div class="flex audio">
<div class="time-text">00:{{ cTime < 10 ? '0'+ cTime : cTime}}</div>
<div class="bar">
<a-progress :percent="item.percent" :showInfo="false" :stroke-color="{'0%': '#108ee9','100%': '#87d068'}"/>
</div>
<div class="right-time time-text">00:{{item.voice_duration < 10 ?'0'+item.voice_duration:item.voice_duration}}</div>
</div>
</div>
</a-tooltip>
</div>
</div>
主要是这些重写的样式
<style lang="less">
.tooltip {
min-width: 900px !important;
}
.selectVoice{
.ant-checkbox-wrapper .ant-checkbox-inner,
.ant-checkbox .ant-checkbox-inner,
.ant-checkbox-input + .ant-checkbox-inner{
border: transparent !important;
}
// 鼠标hover时候的颜色
.ant-checkbox-wrapper:hover .ant-checkbox-inner,
.ant-checkbox:hover .ant-checkbox-inner,
.ant-checkbox-input:focus + .ant-checkbox-inner{
border: transparent !important;
}
// 设置选中的颜色
.ant-checkbox-checked .ant-checkbox-inner,
.ant-checkbox-indeterminate .ant-checkbox-inner {
background-color: #ffffff;
border: transparent;
}
}
</style>
下面是整个的样式
.items{
min-width: 1500px;
.item{
border: 1px solid rgba(215, 215, 215, 1);
border-radius: 4px;
width: 24%;
height: 150px;
margin-top: 20px;
margin-left: 1%;
position: relative;
.a_tool{
position: relative;
top: 7%;
right: -88%;
letter-spacing:3px;
z-index: 999;
}
//checked的默认样式
.selectVoice{
position: absolute;
width: 100%;
height: 100%;
display: none;
z-index: 100;
/deep/.ant-checkbox::after {
visibility: hidden !important;
}
}
.delete{
position: absolute;
left: 0;
top: 0;
background-color: rgba(127, 127, 127, 0.498);
height: 32px;
width: 100%;
color: #fff;
justify-content: flex-end;
padding-right: 10px;
display: none !important;
z-index: 50;
.btn{
cursor: pointer;
}
}
.img{
width: 45%;
height: 45%;
position: absolute;
top: 10%;
left: 4%;
background-size: contain;
background-position: left;
background-repeat: no-repeat;
.time{
position: relative;
left: 84px;
top: 45px;
font-size: 18px;
color: rgba(0, 0, 0, 0.685);
}
.span{
position: relative;
left: 85px;
top: -35px;
font-size: 18px;
}
}
.title{
.bar {
width: 70%;
height: 25px;
margin:0 5px;
//播放按钮的样式
img{
position: relative;
left: 15px;
top: 75px;
z-index: 999;
&:hover{
background: url('../../../assets/materialManagement/onFrame.png');
}
}
}
//鼠标移到div上的样式
&:hover{
border-color: rgb(36, 117, 252);
.selectVoice{
display: inline-block !important;
}
.delete{
display: flex !important;
}
}
}
//动态类
.frame{
border: 1px solid rgb(36, 117, 252);
background-image: url('../../../assets/materialManagement/frame-on.png');
background-repeat: no-repeat;
background-position: right bottom;
}
点击div实现选中效果的更多相关文章
- 利用this属性实现点击按钮变色.选中效果
浏览器宿主的全局环境中,this指的是window对象. <script type="text/javascript"> console.log(this === wi ...
- 点击div全选中再点击取消全选div里面的文字
想做一个就是点击一个div然后实现的功能是div里面的文字都成选中状态,然后就可以利用浏览器的自带的复制功能,任意复制在哪里去了 在网上百度了一下 然后网上的答案感觉很大的范围 然后一些搜索 然后就锁 ...
- jQuery实现点击单选按钮切换选中状态效果
实现效果:第一次点击单选按钮时选中该按钮,再次点击时取消选中该单选按钮. 关键就是要将单选按钮原来的值保存起来,第二次点击时.如果原来选中则取消,否则选中. 看代码吧,是用jQuery实现的,功能虽小 ...
- checkbox复选框和div click事件重叠,点击div后复选框也被选中,同时改变div颜色,否则则不选中
checkbox复选框和div click事件重叠,点击div后复选框也被选中,同时改变div颜色,否则则不选中 <!DOCTYPE html> <html lang=" ...
- 使用Vue.js实现列表选中效果
实际项目中,我们会遇到很多类似的需求,一个列表,需要点击其中一条高亮显示.熟悉JQuery的同学说这个太简单了.可以给这个选中的element设置一个active的class.配合Css样式,让ac ...
- css3实现逐渐变大的圆填充div背景的效果
手机端现在的一些应用会运用上这样一个效果,就是duang的一下出现一个圆变大直到填充整个div,动感十足. 想到css3的scale属性,就自己来实现一下. <div id="bcd& ...
- js星级评分点击星级评论打分效果
html代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www ...
- jQuery实现的Div窗口震动效果实例
本文实例讲述了jQuery实现的Div窗口震动效果.分享给大家供大家参考.具体如下: 这是一款jQuery窗口震动效果代码,在Div边框内点击一下鼠标,它就开始震动了,适用浏览器:IE8.360.Fi ...
- js星级评分点击星级评论打分效果--收藏--转载
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- android实现对导航Tab设置下划线选中效果
技术人员核心竞争力还是技术啊.努力提高各种实现效果.加油哦! 直接看效果.此linearLayout只有两个Button ,当选中Button1,Button1有个下划线选中效果.当选中Buton2, ...
随机推荐
- Web安全与渗透测试笔记
Web安全与渗透测试笔记 @author: lamaper 一.基本网络知识 (一)网络是怎样联通的 TCP/IP协议 Internet Http协议 (二)Http协议 http请求 一个完整的Ht ...
- htmlApk:一个轻松在线打包生成双端app应用的网站
htmlApk平台,基于HTML打包制作APP,只要有手机网站或者HTML文件,3分钟即可生成app多端应用,同时拥有苹果版和安卓版双系统APP,快速进入移动互联时代. 全面支持h5网址打包,可设置图 ...
- xh_零基础网站渗透第一部
一.认识常见网站类型 1.1asp:asp是动态服务器页面(active server page)的英文缩写.是微软公司开发的代替cgi脚本程序的一种应用,它可以与数据库和其它程序进行交互,是一种简单 ...
- 软件工程日报三——创建一个简单app和SDK的介绍
昨天讲安卓studio和gradle等软件和环境都配置成功,今天开始创建第一个app. 一.打开Android studio,创建一个新文件,点击File,选择New Project里面的Empty ...
- gopher必读文章
Getting Started with Go Programminghttps://www.programiz.com/golang/getting-startedHow to Write Go C ...
- go语言学习教程
go语言学习教程 集合了连接go routine.go连接redis.go连接kafka等示例 https://github.com/fastbpmn/go-study TRANSLATE with ...
- (0828)【vivado版本-对仿真工具版本要求】
(1)https://blog.csdn.net/Alonger1988/article/details/120506385 vivado,vsim版本兼容问题 (2)版本匹配:http://deng ...
- SpringCloudEureka上篇
SpringCloudEureka上篇 本文学习自<<重新定义SpringCloud>> Eureka简介 Eureka是Netflix公司开源的一款服务发现组件,该组件提供的 ...
- stl算法汇总
- P5736 质数筛
原题连接 一看到这个熟悉的输入,我们就立马反应过来要请出一维数组来记录一下输入的数据.现在数据的存储解决了,紧接着来剖析一下步骤: 输入数据 一个一个的判断是否为质数 筛去合数 输出质数 理清了思路后 ...