点击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, ...
随机推荐
- Springboot+Vue实现短信与邮箱验证码登录
体验网址:http://mxyit.com 示例 1.新增依赖 <!-- 短信服务 --> <dependency> <groupId>com.aliyun< ...
- boss直聘上看信息 但是不会显示已读
大家在boss直聘上看 想看的boss回你的信息但是又不想显示已读 可以按F12 打开控制台 查找标出文件 查看lastmsg文本里面就是最后一次发你的信息
- Microsoft Project 使用教程
Microsoft Project使用教程 一.新建项目 1. Project界面操作 "文件" -→ "新建" -→ "空白项目" 建议在 ...
- 2022强网拟态 WHOYOUARE
2022强网拟态 WHOYOUARE 先说一下这个思路 由于禁用了__proto__所以我们可以通过constructor.prototype来绕过 之前一直不明白为什么是这样绕过的后来仔细研究了一下 ...
- gcc 中weak弱函数
1.weak弱函数 weak 函数用于定义变量或者函数.弱函数一般用于多个模块间的交互接口 int __attribute__((weak)) test_lib_a(int a, int b) { p ...
- 网络-6 IPV6(上)
一.iPv4与ipv6对比 1.ipv4与ipv6优缺点 1.1 Ipv4与ipv6对比,ipv4中的切片使用的三个字段:identification flags fragment offse ...
- smartgit 安装
下载 https://www.syntevo.com/smartgit/download/ 破解删掉
- spring boot2 jpa分页查询百万级数据内存泄漏
分页查询百万级数据,查询处理过程中发现内存一直飙升,最终处理程序会挂掉,通过jvisualvm可以发现频繁ygc 和fgc ,另外通过 jmap -histo:live ${pid} 命令可以看到jp ...
- GuzzleHttp示例
一般请求 $httpClient = new Client([ 'timeout' => 5 ]); $request = $httpClient->post("http://l ...
- R7-3 汉诺(Hanoi)塔问题
R7-3 汉诺(Hanoi)塔问题 分数 20 全屏浏览题目 切换布局 作者 张高燕 单位 浙大城市学院 古代某寺庙中有一个梵塔,塔内有3个座A.B和C,座A上放着64个大小不等的盘,其中大盘在下,小 ...