位置元素固定在图片旁边 [英] position element fixed beside image
问题描述
伙计们,我很难解释,但我会尽力而为. 我身边有一个共享div
Hey guys it a bit hard for me to explain, but I'll try as best I can. I have a sharing div on my side
<div class="share">
我想将其固定在屏幕顶部的中心:图像左侧的50%. 我尝试了很多CSS动作,但没有成功.
And I want to fixe it in the center of the screen top:50% on left of the image. I tried many css thing but no success.
这是网页 http://giantgag.com/?p=10272
它不适用于所有屏幕分辨率.共享按钮会移到图像上
It doesn't work with all screen resolution. The sharing buttons goes over the image
推荐答案
实际上,css工作正常. top:50%
将div的最高点与顶部保持50%的距离,这就是您在网站上看到的内容.
为了获得正确的解决方案(无论屏幕大小如何),请使用javascript将onload的位置指定为div.
Actually the css is working fine. top:50%
keeps the top point of div at 50% distance from top which is what you are seeing in your site.
For correct solution irrespective of any screen size, use javascript to give the position to div at onload.
这篇关于位置元素固定在图片旁边的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!