高度变化,使用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的更多相关文章

  1. 点击单个cell高度变化的动画效果

    点击单个cell高度变化的动画效果 效果 说明 1. 点击单个cell的时候,其展开与缩放动画实现起来是很麻烦的,做过相关需求的朋友一定知道其中的坑 2. 本例子只是提供了一个解决方案,为了简化操作, ...

  2. js监听某个元素高度变化来改变父级iframe的高度

    最近需要做一个iframe调用其他页面内容,这个iframe地址是可变化的,但是里面的内容高度不确定且里面内容高度可调整,所以需要通过监听iframe里面body的高度变化来调整iframe的高度. ...

  3. CSS父元素高度随子元素高度变化而变化

    <html> <body> <head> <style> #menu{width:1000px;overfloat:hidden;} /* width: ...

  4. jquery实现元素高度变化页面变化

    试了几种方法包括有资料说的h5新特性,都没能满足我的需求.我的需求如下: 元素高度是动态可变的,比如可拖动teatarea元素 最后用到了指针监听事件解决了 @参考文档 $(document).mou ...

  5. 修改某个UITextField的键盘的返回键类型以及监听键盘的高度变化,取到键盘动画退出弹出的时间,一起随着键盘顶出来或者压下去,

    1.修改某个UITextField的键盘的返回键类型: [_bottomTextView setReturnKeyType:UIReturnKeyDone]; 1.1.textFied点击return ...

  6. css 动画 transition和animation

    本文参考:http://www.ruanyifeng.com/blog/2014/02/css_transition_and_animation.html 1. transition基本用法: < ...

  7. CSS动画-transition/animation

    HTML系列: 人人都懂的HTML基础知识-HTML教程(1) HTML元素大全(1) HTML元素大全(2)-表单 CSS系列: CSS基础知识筑基 常用CSS样式属性 CSS选择器大全48式 CS ...

  8. 关于隐藏元素高度的问题 css visibility:hidden 与 display:none的区别

    其实这是一个老问题了,s visibility:hidden 与 display:none 共同点就是都会似的元素不可见.但是 visibility:hidden 的DOM元素是占用空间的,会挤占其他 ...

  9. 高度随每片内容的高度变化的swiper react-native-unfixed-height-swiper

    高度随每片内容的高度变化的swiper    react-native-unfixed-height-swiper 内容可以文本 图片 视频 本例里面的为文本 使用方式1. npm i react-n ...

随机推荐

  1. 使用icepdf将pdf文件转换成照片(以及隐藏的一个bug)

    首先引入依赖: <dependency> <groupId>org.apache.pdfbox</groupId> <artifactId>pdfbox ...

  2. wordpress时间函数the_time() 实例解读

    wordpress the_time()时间函数想必大家多多少少都会用到,但是要自定义一些时间相对没那么熟悉了,随ytkah一起来看看吧.我们知道时间函数基础调用是<?php the_time( ...

  3. Redux的图文模型

    Also these are really nice (from http://slides.com/jenyaterpil/redux-from-twitter-hype-to-production ...

  4. python - 将数据转换成 excl 表格, json 等文件 (dajngo - 打开网页后自动下载)

    本篇只讲述怎么用. 具体 tablib  更多详细用法可参考博客 : https://blog.csdn.net/liangyuannao/article/details/41476277 # 不得不 ...

  5. Zigzag Iterator II

    Description Follow up Zigzag Iterator: What if you are given k 1d vectors? How well can your code be ...

  6. LeetCode 491. Increasing Subsequences

    原题链接在这里:https://leetcode.com/problems/increasing-subsequences/ 题目: Given an integer array, your task ...

  7. learning shell monitor prog function

    [Purpose]        Shell script monitor prog function   [Eevironment]        Ubuntu 16.04 bash env   [ ...

  8. 验证码破解 | Selenium模拟登录知乎

      import requests import re import execjs import time import hmac from hashlib import sha1 class Zhi ...

  9. Linux下g++编译thread出错的的解决方法

    错误如下图所示: 因为thread是C++11新加入的特性,所以我们在用g++编译的时候不能直接用,需要在g++后面加上 -std=c++0x -pthread 如果是gcc编译多线程的话则应该要用 ...

  10. Xilinx ISE中Synplicity.ucf无法加上去的问题

    在Xilinx ISE中使用Synplify pro进行综合时,有时出现无法将synplicity.ucf添加进工程的问题.这时可以在其它目录下备份synplicity.ucf, 然后使用clean ...