javascript - 将鼠标悬停在 React 中的图像上时如何将基本过渡应用于文本
问题描述
我<div>
在它们下面有 3 ,其中包含一些文本,当相应的图像像这样悬停在上面时会显示这些文本:
这是我的代码,我正在使用 React:
<div className = "Page">
<div className = "About">
<h1 className = "Headerr-1">We at flower shop</h1>
<h1 className = "Headerr-2">dedicate ourselves to providing you the best flowers for all occations</h1>
<p className = "paragraph-1"> we use some of the best tools to fertilize our flowers so it can meet your every need</p>
<p className = "paragraph-2" >here is some testimoney from our clients</p>
<div className = " testimony-container">
<img src = {Man} width = "400" height = "400" className = "man-img" />
<img src = {Woman} width = "400" height = "400" className = "woman-img" />
<img src = {Miles} width = "400" height = "400" className = "miles-img" />
<div className = "man-text-container">
<p className = "man-p"> ''I was in dire need of a quick way to get my flowers
on time for my wedding day, I would like to thank Flower
Shop for their efforts on showing up in time.''</p>
<p className = "man-title">
-Melvin Jones
</p>
</div>
<div className = "woman-text-container">
<p className = "woman-p"> ''I needed some fresh picked flowers as a gift for my
grandmother's birthday, and a friend referenced flowershop to me. Suffice to say
I don't have any regrets!''
</p>
<p className = "woman-title">
-Vanessa Richardson
</p>
</div>
<div className = "miles-text-container">
<p className = "miles-p"> ''An old friend of mine was sick and I was looking to
purchase some flowers as a gift and send it to the hospital where he was resting.
I thank Flower Shop for their beautifully picked flowers.''
</p>
<p className = "miles-title">
-Miles Edgeworth
</p>
</div>
</div>
</div>
</div>
我想做的是添加一个基本的过渡,以缓慢的方式显示文本。我尝试使用opacity
,但是当我希望文本在悬停动作中淡入淡出时,文本刚刚开始以一种奇怪的方式跑向屏幕。
最好的方法是什么?
解决方案
使用不透明度对我来说效果很好:
.man-text-container,
.miles-text-container,
.woman-text-container {
opacity:0;
transition: opacity 300ms ease-in-out;
-webkit-transition: opacity 300ms ease-in-out;
-moz-transition: opacity 300ms ease-in-out;
}
.man-img:hover~.man-text-container,
.woman-img:hover~.woman-text-container,
.miles-img:hover~.miles-text-container {
opacity: 1;
}
你的 CSS 是什么样的?
推荐阅读
- java - 当您在片段中打开新活动时,应用程序会停止
- centos - 在 Virtual Box 中运行的 CentOS 中鼠标停止单击
- css - magenta.js Visualizer() 呈现模糊的笔记
- javascript - 打字稿抱怨显式类型没有索引签名
- kubernetes - 在 Kubernetes 上设置 glusterfs 时出错:volume create: heketidbstorage: failed: Host not connected
- php - 将 laravel 供应商文件夹上传到 cpanel 时出错
- typescript - TS2605:JSX 元素类型'VNode
| 看法 ' 不是 JSX 元素的构造函数 - autodesk-forge - 模型浏览器如何按楼层或默认分类并一起显示
- c++ - 为什么必须复制 libstdc++-6.dll 才能运行我的 c++ 程序?
- javascript - 在 Javascript 中操作 DOM 不起作用