css - 使 CSS 平滑动画转到 "both ways"?

标签 css

已经检查了大量答案,但找不到我需要的答案。我猜是因为我找不到合适的词来表达它!
我有一个高度设置为 80px 的 textarea,当你将鼠标悬停在它上面时,会出现一个平滑的 webkit它扩展到 310px 的动画。这一点工作正常,只是当您将鼠标从 textarea 上取下时,它会立即恢复为 80px,此时最好将其再次平滑压缩。
我将如何修改此代码以使其做到这一点?

textarea
{
    width: 1100px;
    height: 80px;
    font-weight: bold;
    font-size: 20px;
    border-radius: 10px;
    border-color: #000000;
    background-color : #000000;
    color: #FFFFFF;
    opacity: 0.7;
    font-family: "Times New Roman";
    vertical-align: middle;
}
textarea:hover
{
    font-weight: bold;
    font-size: 31px;
    border-radius: 10px;
    opacity: 1;
    width: 1100px;
    height: 310px;
    -webkit-transition: height 1s;
}

最佳答案

只需将您的过渡线放在 textarea 上本身,像这样:

textarea
{
    width: 1100px;
    height: 80px;
    font-weight: bold;
    font-size: 20px;
    border-radius: 10px;
    border-color: #000000;
    background-color : #000000;
    color: #FFFFFF;
    opacity: 0.7;
    font-family: "Times New Roman";
    vertical-align: middle;
    -webkit-transition: height 1s;
}
textarea:hover
{
    font-weight: bold;
    font-size: 31px;
    border-radius: 10px;
    opacity: 1;
    width: 1100px;
    height: 310px;
}

这确保所有高度变化(包括鼠标移出)都作为动画应用于文本区域,而不仅仅是悬停。

演示

http://jsfiddle.net/qd4fdfnd/

关于css - 使 CSS 平滑动画转到 "both ways"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28914306/

相关文章:

html - 如何增加 Angular 5 中垫对话框的自动高度?

带有省略号的 CSS3 flexbox 布局在移动 Safari 上不起作用

html - 如何排列或堆叠 div 类

html - 使用具有背景颜色的特定 div,而不影响主体的背景

css 边距,填充样式

jquery - 使用jquery调整div大小并向上移动

css - Bootstrap - 表单内联元素之间的间距

html - 为什么我的花车不工作

c# - 网页显示特殊字符

html - 溢出问题:auto; and chrome