元素高度变化使用动画transition
高度变化,使用transition,没有效果,可以使用max-height替换。
思路:
初始元素max-height:0; 不显示,父元素hover时,重新设置元素的max-height的值,
可以通过el.scrollHeight获取元素的真实高度。
demo:
<div class='demo'>
<div> this is demo</div>
<div class='content' v-hoverAutoHeight>
this is content;this is content;this is content;
this is content;this is content;this is content;this is content;
</div>
</div>
css:
.demo{
.content{
transition: max-height 1s;
max-height:;
overflow: hidden;
}
&:hover .content{
max-height: var(--max-height);
}
}
js
Vue.directive('hoverAutoHeight', {
inserted(el, binding) {
let maxHeight = el.scrollHeight;
console.log(maxHeight);
el.style.setProperty('--max-height', maxHeight + 'px');
}
});
元素高度变化使用动画transition的更多相关文章
- 点击单个cell高度变化的动画效果
点击单个cell高度变化的动画效果 效果 说明 1. 点击单个cell的时候,其展开与缩放动画实现起来是很麻烦的,做过相关需求的朋友一定知道其中的坑 2. 本例子只是提供了一个解决方案,为了简化操作, ...
- js监听某个元素高度变化来改变父级iframe的高度
最近需要做一个iframe调用其他页面内容,这个iframe地址是可变化的,但是里面的内容高度不确定且里面内容高度可调整,所以需要通过监听iframe里面body的高度变化来调整iframe的高度. ...
- CSS父元素高度随子元素高度变化而变化
<html> <body> <head> <style> #menu{width:1000px;overfloat:hidden;} /* width: ...
- jquery实现元素高度变化页面变化
试了几种方法包括有资料说的h5新特性,都没能满足我的需求.我的需求如下: 元素高度是动态可变的,比如可拖动teatarea元素 最后用到了指针监听事件解决了 @参考文档 $(document).mou ...
- 修改某个UITextField的键盘的返回键类型以及监听键盘的高度变化,取到键盘动画退出弹出的时间,一起随着键盘顶出来或者压下去,
1.修改某个UITextField的键盘的返回键类型: [_bottomTextView setReturnKeyType:UIReturnKeyDone]; 1.1.textFied点击return ...
- css 动画 transition和animation
本文参考:http://www.ruanyifeng.com/blog/2014/02/css_transition_and_animation.html 1. transition基本用法: < ...
- CSS动画-transition/animation
HTML系列: 人人都懂的HTML基础知识-HTML教程(1) HTML元素大全(1) HTML元素大全(2)-表单 CSS系列: CSS基础知识筑基 常用CSS样式属性 CSS选择器大全48式 CS ...
- 关于隐藏元素高度的问题 css visibility:hidden 与 display:none的区别
其实这是一个老问题了,s visibility:hidden 与 display:none 共同点就是都会似的元素不可见.但是 visibility:hidden 的DOM元素是占用空间的,会挤占其他 ...
- 高度随每片内容的高度变化的swiper react-native-unfixed-height-swiper
高度随每片内容的高度变化的swiper react-native-unfixed-height-swiper 内容可以文本 图片 视频 本例里面的为文本 使用方式1. npm i react-n ...
随机推荐
- vue router 中,children 中 path 为空字符串的路由,是默认打开的路由(包括在 el-tabs 中嵌套路由的情况)
详见该页面的最后一个代码块:https://router.vuejs.org/zh/guide/essentials/nested-routes.html#%E5%B5%8C%E5%A5%97%E8% ...
- oracle之随机数
一.首先创建一个测试表 select * from DIM_IA_TEST1 生成随机数 select t.*,rownum rn from (select * from DIM_IA_TEST1 ...
- WHAT IS GAME-BASED LEARNING?
https://www.growthengineering.co.uk/what-is-game-based-learning/ Gamification and game-based learnin ...
- The Difference between Gamification and Game-Based Learning
http://inservice.ascd.org/the-difference-between-gamification-and-game-based-learning/ Have you trie ...
- 无向图边双联通分量 tarjan 模板
#include <bits/stdc++.h> using namespace std; const int MAXN = 100005; const int MAXM = 500005 ...
- RabbitMQ六种队列模式-路由模式
前言 RabbitMQ六种队列模式-简单队列RabbitMQ六种队列模式-工作队列RabbitMQ六种队列模式-发布订阅RabbitMQ六种队列模式-路由模式 [本文]RabbitMQ六种队列模式-主 ...
- (11)树莓派3 有线网卡静态IP设置
https://www.cnblogs.com/10e-6/p/5778355.html 树莓派设置静态IP地址 首先终端输入: ifconfig 查看树莓派默认分配的动态IP地址. 图 1-4 配置 ...
- Dinner Bet Gym - 101174D (期望dp)
Problem D: Dinner Bet \[ Time Limit: 1.5 s \quad Memory Limit: 256 MiB \] 题意 题意是两个人在玩游戏,一共有\(n\)张牌,这 ...
- LeetCode 981. Time Based Key-Value Store
原题链接在这里:https://leetcode.com/problems/time-based-key-value-store/ 题目: Create a timebased key-value s ...
- AlexNet梳理
创新点 成功的使用relu函数替代了sigmoid函数,解决了使用sigmoid的梯度消散问题 成功的在全连接层使用dropout 成功的使用重叠最大池化 提出了LRN 利用GPU进行运算 数据增强2 ...