且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在页面上移动内容时悬停文字?

更新时间:2023-10-25 11:43:10

c $ c> display:none 。在显示之前,元素不在DOM的流中。听起来你发现,不同的浏览器处理 visibility 属性不同

Michael_B is correct about display: none. The element is not in the flow of your DOM until it becomes displayed. As it sounds like you've discovered, different browsers handle the visibility property differently.

如果你想要做的只是显示悬浮照片下的文本具有周围内容bounce,一个很容易的伎俩是将文本放在文档的流程中,无论你想要显示它,并用 color:transparent

If what you are trying to do is merely display the text under the photos on hover without having the surrounding content "bounce", a really easy trick is to put the text in the flow of the document wherever you want it to be displayed and style it with color: transparent.

因此,如果不能看到您的HTML,并且完全基于您提供的代码,可能的解决方案将如下所示:

So, without being able to see your HTML and based solely on your provided code, a possible solution would look like this:

.photo1-content{
    color: transparent;
}

.photo1:hover .photo1-content{
    color: black;
}

希望这有助!