Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 带页的DIV浮动_Css - Fatal编程技术网

Css 带页的DIV浮动

Css 带页的DIV浮动,css,Css,如何让DIV与我的页面一起浮动?目前我有如下设置: 我可以使用以下CSS来实现这一点: 代码: 但是,当标题滚动时,右DIV向上移动,与顶部保持10像素的距离,并与页面一起滚动,除非标题在那里,否则我怎么能得到它呢 要做到这一点,您需要JavaScript 您的站点已经在使用它,所以使用JavaScript来实现这一点应该没有问题 一些教程: 此答案使用 您可以将其放入$.ready()函数中 var int_header_height = 10; //put pixel value he

如何让DIV与我的页面一起浮动?目前我有如下设置: 我可以使用以下CSS来实现这一点: 代码:


但是,当标题滚动时,右DIV向上移动,与顶部保持10像素的距离,并与页面一起滚动,除非标题在那里,否则我怎么能得到它呢

要做到这一点,您需要JavaScript

您的站点已经在使用它,所以使用JavaScript来实现这一点应该没有问题

一些教程:

此答案使用

您可以将其放入
$.ready()
函数中

var int_header_height = 10; //put pixel value height of header here
if ($(document).scrollTop() <= int_header_height) {
    $('div.stayStill').css('position','absolute').css('top','0px');
} else {
    $('div.stayStill').css('position','fixed').css('top','10px');
}
var int_header_height=10//将标题的像素值高度放在此处
if($(文档).scrollTop()
var int_header_height = 10; //put pixel value height of header here
if ($(document).scrollTop() <= int_header_height) {
    $('div.stayStill').css('position','absolute').css('top','0px');
} else {
    $('div.stayStill').css('position','fixed').css('top','10px');
}