HTML   发布时间:2022-04-14  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了html – 如何在悬停时展开div及其内容?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试创建一个在悬停时扩展的div,但无法弄清楚如何使用div扩展内容.我尝试了一些溢出选项,但它们没有用.
.grow {
  padding: 5px 5px 5px 5px;
  border-radius:10px;
    height: 50px; 
    width: 22%; 
    margin: 5px 1% 5px 1%; 
    float: left; 
    position: relative; 
    transition:height 0.5s; 
    -webkit-transition:height 0.5s; 
    text-align: center;

}
.grow:hover {
    height: 115px; /* This is the height on hover */
}
<div class="grow" style="BACkground-color: #2a75a9;">
    <h2>title</h2> <br>
    Contrary to popular belief,Lorem Ipsum is not simply random text.  It has roots in a piece of classical LaTin literature
</div>

这是JSFiddle

解决方法

添加溢出:隐藏到父(.grow)容器以隐藏描述.这将揭示悬停的描述.

此外,而不是使用< br />标记,将文本包装在< p>标签.

.grow {
  padding: 5px 5px 5px 5px;
  border-radius: 10px;
  height: 49px;
  width: 22%;
  margin: 5px 1% 5px 1%;
  float: left;
  position: relative;
  transition: height 0.5s;
  -webkit-transition: height 0.5s;
  text-align: center;
  overflow: hidden;
}
.grow:hover {
  height: 145px;
}
<div class="grow" style="BACkground-color: #2a75a9;">
  <h2>title</h2> 
  <p>Contrary to popular belief,Lorem Ipsum is not simply random text. It has roots in a piece of classical LaTin literature</p>
</div>

大佬总结

以上是大佬教程为你收集整理的html – 如何在悬停时展开div及其内容?全部内容,希望文章能够帮你解决html – 如何在悬停时展开div及其内容?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。