位置:固定不固定?

时间:2013-04-04 05:44:13

标签: html css facebook-like position fixed

我想让我的facebook按钮保持在左上角,当用户向下滚动它跟随它们...我的代码出了什么问题?它显示但是当我向下滚动时它不会随着滚动而移动。在safari和firefox的最新版本本地测试。请帮忙!

 topleft{
   position: fixed;
   top: 0;
   left: 0;
 }

<top> FACEBOOK "LIKE BUTTON" IFRAME CODE HERE </top>

3 个答案:

答案 0 :(得分:2)

您没有正确选择喜欢按钮。您需要为css选择添加一个类属性。

尝试类似

的内容
<div class="facebook">FACEBOOK IFRAME</div>

注意“.facebook”而不只是“facebook”。

.facebook {
   position: fixed;
   top: 0;
   left: 0;
}

答案 1 :(得分:1)

HTML中没有top标记。

CSS类名选择器前面应加.(句点)。

 topleft{
   position: fixed;
   top: 0;
   left: 0;
 }

应该是

.topleft{
   position: fixed;
   top: 0;
   left: 0;
 }

将您创建的样式分配给iframe应该有效。

 <iframe class="topleft" ...>
    ...
 </iframe>

JSFiddle

答案 2 :(得分:1)

问题可能是

forplepleft class

.topleft{
position: fixed;
top: 0;
left: 0;
}

for topleft id

#topleft{
position: fixed;
top: 0;
left: 0;
}

否则它应该有效。

相关问题