【发布时间】:2016-05-26 22:10:55
【问题描述】:
我遇到了许多关于在 Stackoverflow 上悬停时显示图像的问题,但找不到解决我的问题的方法。
现在,当我将鼠标悬停在段落的背景上时,我设法在该段落的背景中显示了一张图片。 See on JSFiddle.
理想情况下,我想实现什么:一旦我将鼠标悬停在段落内的 Example1 上,我想在背景中显示 Image1,而不是在段落下方,而是在背景中居中,在所有元素下方。 As pictured here。
将鼠标悬停在 Example2 上会显示 Image2,Example3 会显示 Image3。
HTML
<div id="imgbg">
<p>Portfolio:</p>
<p>I worked with:<br />
Example1, Example2, Example3, Example4, Example5
</p>
</div>
CSS
#imgbg {
height: 100%;
width: 100%;
}
#imgbg:hover {
background-image: url('http://i.imgur.com/9bbjE1Mb.jpg');
}
有人有解决办法吗?非常感谢。
【问题讨论】: