[英]Hover over effect pushing image down
Here is an image of the media div
with the on hover X
I have: 这是带有我
on hover X
的media div
的图像:
Here is an image of when you click on the div and upload a photo. 这是单击div并上传照片时的图像。 As you can see it fits nicely inside the box.
如您所见,它非常适合包装盒。
Finally here is a div when I hover over
the image to see the X
. 最后,当我将
hover over
图像上以查看X
时,这是一个div。
As you can see the image got pushed down. 如您所见,图像被推下。 My end result is instead to have it hover over the image and not affect the images placement
我的最终结果是将其悬停在图像上,并且不影响图像的放置
Here's my CSS: 这是我的CSS:
.x {
color:red;
#width:50px;
#height:50px;
display:none;
#left:50px;
}
.MediaPreview:hover > .x {
display:block;
}
.MediaPreview {
position: absolute;
width: 128px;
height: 72px;
background-color: #e0e0e0;
cursor: default;
}
Here is my HTML: 这是我的HTML:
<div class="MediaPreview" style="left: 10px; bottom: 10px;">
<span>Image or video, required</span>
<div class="x">x</div>
</div>
Try this? 尝试这个?
.x {
color:red;
#width:50px;
#height:50px;
display:none;
top: 10px;
left: 10px;
position: absolute;
z-index: 1;
}
.MediaPreview:hover > .x {
display:block;
}
.MediaPreview {
position: absolute;
width: 128px;
height: 72px;
background-color: #e0e0e0;
cursor: default;
}
You need to apply position:absolute
to .x
, not .MediaPreview
. 您需要将
position:absolute
应用于.x
,而不是.MediaPreview
。 Try this: 尝试这个:
.x {
color:red;
display:none;
position: absolute;
top: 0;
left: 0;
}
.MediaPreview:hover > .x {
display:block;
}
.MediaPreview {
position: relative;
width: 128px;
height: 72px;
background-color: #e0e0e0;
cursor: default;
}
you can try this: https://jsfiddle.net/maky/gqn1nrxj/ 您可以尝试以下方法: https : //jsfiddle.net/maky/gqn1nrxj/
.x {
color:red;
display:none;
position: absolute;
top: 0;
left: 0;
}
.MediaPreview:hover > .x {
display:block;
}
.MediaPreview {
position: relative;
padding:10px;
width: 200px;
height: 200px;
background-color: #e0e0e0;
cursor: default;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.