【发布时间】:2014-08-07 19:20:40
【问题描述】:
我正在尝试获取一个始终显示跨度的 div,并将鼠标悬停在该 div 上时显示其下方的段落。我有什么工作,除了我希望其中一些 div 转换宽度,以便它们向下转换然后离开。默认值(我猜是浏览器默认值)似乎总是先下后右。
链接到下面的小提琴和代码。有两个带有标题文本的红色框 div,当您将鼠标悬停在它们上方时,宽度会扩大并显示其下方的段落。我要做的是使右下角的 div(Title Here2 文本)向左过渡。所以红色背景根本不会向右过渡。
注意:页面上 div 的位置不能改变。
http://jsfiddle.net/szfiddle/qP5fW/1/
HTML
<div class="hpBox">
<span>Title Here</span>
<p>Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here.</p>
</div>
<div class="hpBox hpBox2">
<span>Title Here2</span>
<p>Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here. Text here.</p>
</div>
CSS
.hpBox {
display: inline-block;
padding: 10px;
background: red;
-webkit-transition: 1s linear;
transition: 1s linear;
max-width:200px;
max-height:22px;
position:absolute;
}
.hpBox p {
max-height: 0;
max-width: 0;
overflow: hidden;
-webkit-transition: 2s linear;
transition: 2s linear;
}
.hpBox:hover {
max-width:400px;
max-height:200px;
}
.hpBox:hover p {
max-height: 200px;
max-width: 400px;
}
.hpBox2 {
left:60%;
top:250px;
}
【问题讨论】:
标签: html css css-transitions