2012-12-02 23 views

回答

3
#myElement { 
    position:fixed; 
    top:50px; 
    left:0px; 
} 

元素將被相對於瀏覽器窗口中定位和滾動/調整大小不會影響它

0

您只需要使用作爲position:fixed;一些造型器的位置。你也可以使用css規則,下面是一個例子。

聯樣式

<div style="position:fixed; top:100px; left:0px;"> 
    your content 
</div> 

用css

<html> 
    <style> 
     #element { 
      position:fixed; top:100px; left:0px; 
     } 
    </style> 
    <body> 
     <div id="element"> 
      your content 
     </div> 
    </body> 
</html> 
+0

不好的做法,把造型中的HTML代碼。 – Konst

+0

使用CSS還添加了代碼 –

+2

內聯樣式也是CSS,順便說一下 –