CSS 中哪個屬性用於控制背景圖片的滾動?


若要設定背景圖片的滾動,請使用 background-attachment 屬性。

示例

你可以嘗試執行以下程式碼來學習如何使用 background-attachment 屬性

<!DOCTYPE html>
<html>
   <head>
      <style>
         body {
            background-image: url('/css/images/css.jpg');
            background-repeat: no-repeat;
            background-attachment: fixed;
            background-attachment:scroll;
         }.
      </style>
   </head>
   <body>
      <p>The background-image is fixed. Try to scroll down the page.</p>
      <p>The background-image is fixed. Try to scroll down the page.</p>
      <p>The background-image is fixed. Try to scroll down the page.</p>
      <p>The background-image is fixed. Try to scroll down the page.</p>
      <p>The background-image is fixed. Try to scroll down the page.</p>
      <p>The background-image is fixed. Try to scroll down the page.</p>
      <p>The background-image is fixed. Try to scroll down the page.</p>
      <p>The background-image is fixed. Try to scroll down the page.</p>
      <p>The background-image is fixed. Try to scroll down the page.</p>
   </body>
</html>

更新於: 30-Jan-2020

799 瀏覽

開啟你的 職業

完成課程以獲得認證

開始
廣告
© . All rights reserved.