body {
  background-color: #666e8e;
  margin: 3rem;
}

#testlink {
  text-decoration: none;
}

#testlink:hover .titles {
  color: #3c2301;
  background: linear-gradient(#7bcfd7 25%, #D2B48C 75%);
}

.test {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  width: auto;
  height: 150px;
  background: linear-gradient(#e97e7e 25%, #3bcee5 75%);
  border-radius: 0% 0% 0% 0% / 0% 0% 0% 0%;
  color: white;
  box-shadow: 20px 20px rgba(0, 0, 0, .15);
  transition: all .8s ease;
  margin: 15px;
}

.test1:hover .description {
  display: block;
  pointer-events: auto;
}

.test:hover {
  border-radius: 0% 0% 90% 90% / 0% 0% 45% 45%;
  box-shadow: 10px 10px rgba(0, 0, 0, .25);
  width: auto;
  height: 450px;
  display: flex;
  justify-content: center;
  align-items: normal;
}

.description {
  display: none;
  position: relative;
  bottom: 400px;
  left: 0;
  width: 90%;
  padding: 0px;
  margin: 0px;
  box-sizing: border-box;
  text-align: center;
  pointer-events: none;
}
<div class="test1">
  <a href="https://youtube.com" id="testlink" target="_blank">
    <h1 class="test">Testing Box</h1>
  </a>
  <p class="description">Test description</p>
</div>

here is the issue

我试图让它只显示文本,但它一直在做重置的事情. 我试过将位置更改为绝对位置,只是将div中的描述和使用自己的css代码,但我所try 的一切都不起作用

推荐答案

当鼠标悬停在元素上时,会出现抽搐效果,这是由于描述文本上的宽度和高度属性以及指针事件的过渡引起的布局偏移.调整过渡特性以排除宽度和高度的更改.仅指定必要的属性,如 colored颜色 、边框半径和盒阴影,以平滑过渡,并在'. prefix'上设置pointer-events:none.这确保了在悬停效果期间避免布局偏移,从而防止抽搐行为. 试用Codepen:https://codepen.io/beth-codes/pen/MWRbzbb?editors=1100

     .test1:hover .description {
        display: block;
        pointer-events: none;
     }

     

Html相关问答推荐

为什么html复选框总是具有只读属性?

srcset和大小总是下载最大的

Flexbox嵌套div溢出

网格容器中的定心元件

将CSS应用于TD标记内的div

在弹性框布局中的第n个元素后强制换行

使具有FLEX父项的溢出自动的子元素收缩

是否可以只使用css而不使用像&;nbsp;这样的HTML符号来实现断字而不换行空格?

动画的停止和启动并不顺利

悬停表格单元格文本时,使元素的字体大小更大,同时保持表格单元格的高度不变

将文本保持在平行四边形内并遵循形状

太多的 Web 视图实例导致手机过热 Swift

高度大于页面高度和页面大于覆盖的 CSS 覆盖

更改标签标签的大小

如何制作一个空的网格模板行来填充剩余空间?

我用 ejs 修复了一个奇怪的语法错误,我想知道问题出在哪里

圆形边框显示在该部分后面.怎么修?

是否可以使用纯 css 创建具有斜角效果的锯齿形边缘?

根据正则表达式 attr 从 read_html 过滤表格

表格布局:固定;文本溢出单元格时不起作用