背景非常简单,当用户悬停/点击时,我希望从元素底部向上滑动一个小标题。见图 1。
有点挖掘说这不能使用 CSS 来完成,但我真的不明白为什么。几个小时后,我想我已经非常接近解决它了,但我无法跨越最后的障碍。
我的逻辑是,如果您的父元素有overflow: hidden,并且您绝对将标题放置在父元素的底部之外,则可以使用 transition 属性为位置值设置动画,使其向上滑动。纯CSS宝贝!
你不能动画高度 - 文本被压碎,元素必须作为一个块移动(尽管不一定呈现为 display:block)。
到目前为止,我已经到了https://jsfiddle.net/zufwavpn/。HTML,
<div class="item-wrapper">
<div class="content">
Hello I am content. All that matters for this method to work is that the item wrapper has a fixed size. In my working project, the width is set to a % value, and the height to rem.
</div>
<div class="popup-title">
<span>A title for my content</span>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
和 CSS(我已经在这里转换为 vanilla CSS),
.item-wrapper{
height:22rem;
position:relative;
overflow:hidden;
color:white;
font-family:sans-serif; …Run Code Online (Sandbox Code Playgroud) 考虑以下情况,可以(作为示例)用于执行单行交换:
let a = (10,20)
console.log(a)
> 20
Run Code Online (Sandbox Code Playgroud)
执行交换的示例
let a = 1, b = 2
a = b + (b=a, 0)
console.log(a, b)
>2,1
Run Code Online (Sandbox Code Playgroud)
我习惯于看到包含函数声明的括号创建自调用函数,但我不确定在上面的情况下发生了什么.如何(10,20)或被(b=a, 0)javascript对待?它是一个返回最终值的函数,还是一个数据类型,当访问它时总会给出最后一个项或其他什么?
为了澄清,我不是在寻找有关如何执行交换的提示,而是对上述语法的解释.