html - 移动(变换:翻译(x,y))文本(
) 在一个 div 中,使它看起来像是隐藏在同一个 div 中
问题描述
基本上我有一个 div,当悬停在它上面时,文本会向右移动。我想实现一些效果,就好像文本在向右移动时丢失在 div 内一样。
.rectangulo_categoria {
border-radius: 34px;
border: 2px solid red;
width: 195px;
height: 50px;
display: flex;
justify-content: center;
align-items: center;
-webkit-box-shadow: 10px 10px 5px 0px rgba(0, 0, 0, 0.75);
-moz-box-shadow: 10px 10px 5px 0px rgba(0, 0, 0, 0.75);
box-shadow: 8px 4px 10px -1px rgba(0, 0, 0, 0.75);
}
.rectangulo_categoria:hover .texto_engranen_1 {
transform: translate(168px, 0px);
opacity: 0;
}
.texto_engranen_1 {
line-height: 1;
pointer-events: none;
z-index: 1;
font-size: 12px;
width: auto;
font-weight: 400;
pointer-events: none;
line-height: 1;
transition: 0.5s all ease-out;
opacity: 1;
color: #343434;
}
<div class="rectangulo_categoria" mdbWavesEffect>
<p class="texto_engranen_1 p-0 m-0">Gestion Recursos de Apoyo Académico</p>
</div>
这是我的完整代码:
解决方案
您可以overflow: hidden;
在 div 上添加一个。我还重新安排了你的课程并删除了一些重复的道具。
.rectangulo_categoria {
border-radius: 34px;
border: 2px solid red;
width: 195px;
height: 50px;
display: flex;
justify-content: center;
align-items: center;
-webkit-box-shadow: 10px 10px 5px 0px rgba(0, 0, 0, 0.75);
-moz-box-shadow: 10px 10px 5px 0px rgba(0, 0, 0, 0.75);
box-shadow: 8px 4px 10px -1px rgba(0, 0, 0, 0.75);
overflow: hidden;
}
.texto_engranen_1 {
line-height: 1;
z-index: 1;
font-size: 12px;
width: auto;
font-weight: 400;
pointer-events: none;
transition: 0.5s all ease-out;
opacity: 1;
color: #343434;
}
.rectangulo_categoria:hover .texto_engranen_1 {
transform: translate(168px, -50%);
opacity: 0;
}
<div class="rectangulo_categoria" mdbWavesEffect>
<p class="texto_engranen_1 p-0 m-0">Gestion Recursos de Apoyo Académico</p>
</div>
编辑
当然检查小提琴上的代码以获得绝对解决方案。主要的变化是我删除了 flex 及其属性,还重置了<p>
.
推荐阅读
- python - 如何在 python 中仅对某些模型变量执行部分 F 测试
- angular - Angular 在组件中无法使用某些样式?
- javascript - discord bot帮助命令没有做任何事情
- mongodb - 使用 mongoDB 作为源时,AWS DMS 不会将 int 升级为 double
- javascript - 正则表达式允许 # 仅在字符串中的字符之间
- c# - Moq 和 xUnit 的单元测试失败 - InvalidOperationException
- reactjs - 如何“模仿”与 React Firebase 云的一对多关系?
- javascript - 碰撞检测html5画布
- stata - 从字符串响应中删除特定字符
- php - 在php中获取2个日期之间的信息