2011-08-09 31 views
-2

我使用wordpress。当滚动页面时,帖子的标题始终固定

用户:用户

通:123ABC

祝文章的标题滚动页面时始终是固定的。 http://www.correnteparaobem.com.br/onde-se-encontra-a-casa-de-deus

例如:

我们打开了一篇文章,标题我们已经制定的标准。 一旦放下页面,它就会保持在网站的顶部。当攀爬屏幕时,他回到起源地。

我试图引导我通过这个教程:http://pt.w3support.net/index.php?db=so&id=1216114

我改变了标题到一个div:

< div class="postheader"> < ? php the_title();> </div> 

我试过的CSS:

. postheader { 

margin: 0.2em 0; 

padding: 0; 

font-size: 18px; 

color: # 3f5e73; 

background-color: # ffffff; 

    color: # 3f5e73; 
    height: 30px; 
    position: absolute; 
    top: 0px; 
    width: 400px; 
    z-index: 100; 
} 

在体内,此脚本:

$ (window). scroll (function (e) { 

    $ el = $ ('. postheader'); 

    if ($ (this). scrollTop()> 0 & & $ el.css ('position')! = 'fixed') { 

    $ ('. postheader'). css ({'position': 'fixed', 'top': '0 px '}); 

    } 

}); 

未得到结果

+1

让我猜。你把包括代码在内的所有东西都转换成Google翻译吗 – genesis

回答

0

在CSS中,使用position: fixed;。此外,检查您的代码中的额外空间...