1. <nobr id="easjo"><address id="easjo"></address></nobr>

      <track id="easjo"><source id="easjo"></source></track>
      1. 
        

      2. <bdo id="easjo"><optgroup id="easjo"></optgroup></bdo>
      3. <track id="easjo"><source id="easjo"><em id="easjo"></em></source></track><option id="easjo"><span id="easjo"><em id="easjo"></em></span></option>
          貴州做網站公司
          貴州做網站公司~專業!靠譜!
          10年網站模板開發經驗,熟悉國內外開源網站程序,包括DEDECMS,WordPress,ZBlog,Discuz! 等網站程序,可為您提供網站建設,網站克隆,仿站,網頁設計,網站制作,網站推廣優化等服務。我們專注高端營銷型網站,企業官網,集團官網,自適應網站,手機網站,網絡營銷,網站優化,網站服務器環境搭建以及托管運維等。為客戶提供一站式網站解決方案?。?!

          CSS background-attachment屬性實例講解

          來源:互聯網轉載 時間:2024-01-29 08:07:19

          background-attachment 屬性用于指定背景圖像是固定的還是隨瀏覽器窗口中頁面的其余部分滾動。

          此屬性具有滾動、固定和本地三個值。它的默認值是滾動,這會導致元素不隨其內容滾動。此屬性的本地值導致元素隨內容滾動。如果我們將該值設置為fixed,則在瀏覽器中滾動時背景圖像不會移動。

          此 CSS 屬性可以支持多個背景圖像。我們可以為每個 background-image 指定不同的 background-attachment 屬性值,用逗號分隔。每個圖像都將與此屬性的相應值匹配。

          用法

          background-attachment:scroll | fixed | local | initial | inherit;

          該屬性的值定義如下。

          屬性值

          scroll:它是防止元素隨內容滾動但隨頁面滾動的默認值。

          fixed:使用此值,背景圖像不會隨元素移動,即使元素具有滾動機制。它會導致圖像被鎖定在一個地方,甚至文檔的其余部分也會滾動。

          local:使用這個值,如果元素有滾動機制,背景圖片會隨著元素的內容滾動。

          initial:它將屬性設置為其默認值。

          inherit:它從其父元素繼承屬性。

          讓我們通過一些插圖來理解這個屬性。

          示例

          在此示例中,我們使用 background-attachment 屬性的滾動值,這是默認行為。所以當頁面滾動時,背景也會隨之滾動。

          <!DOCTYPE html><html><head><title>background-attachment property</title><style>#example {background-image: url("lion.png");font-size:35px;border:4px solid red;color:white;background-position:center;background-color:green;background-repeat:no-repeat;background-attachment:scroll;}</style></head><body><h1> background-attachment:scroll;</h1><p> If there is no scrollbar on your screen, then try to resize the browser's window to see the effect. </p><p ><p>Hi, Welcome to the javaTpoint.com. This site is developed so that students may learn computer science related technologies easily. The javaTpoint.com is always providing an easy and in-depth tutorial on various technologies. No one is perfect in this world, and nothing is eternally best. But we can try to be better.</p></p></body></html>

          輸出

          示例 - 使用固定值

          在此示例中,我們使用 background-attachment 屬性的固定值。該值固定了背景圖像,即使文檔的其余部分滾動,圖像也不會移動。

          <!DOCTYPE html><html><head><title>background-attachment property</title><style>#example {background-image: url("lion.png");font-size:35px;border:4px solid red;color:white;background-position:center;background-color:green;background-repeat:no-repeat;background-attachment:fixed;}</style></head><body><h1> background-attachment:fixed;</h1><p> If there is no scrollbar on your screen, then try to resize the browser's window to see the effect. </p><p ><p>Hi, Welcome to the javaTpoint.com. This site is developed so that students may learn computer science related technologies easily. The javaTpoint.com is always providing an easy and in-depth tutorial on various technologies. No one is perfect in this world, and nothing is eternally best. But we can try to be better.</p></p></body></html>

          輸出

          示例 - 使用本地值

          在此示例中,我們使用 background-attachment 屬性的本地值。在這里, background-image 將隨著元素內容的滾動而滾動。

          <!DOCTYPE html><html><head><title>background-attachment property</title><style>#example {background-image: url("lion.png");font-size:35px;border:4px solid red;color:white;background-position:center;background-color:green;background-repeat:no-repeat;background-attachment:local;}</style></head><body><h1> background-attachment:local;</h1><p> If there is no scrollbar on your screen, then try to resize the browser's window to see the effect. </p><p ><p>Hi, Welcome to the javaTpoint.com. This site is developed so that students may learn computer science related technologies easily. The javaTpoint.com is always providing an easy and in-depth tutorial on various technologies. No one is perfect in this world, and nothing is eternally best. But we can try to be better.</p></p></body></html>

          輸出

          現在,讓我們看另一個示例,其中我們為元素使用多個背景圖像。

          示例

          在這里,有兩個背景圖像我們正在應用 background-attachment 屬性。第一張圖片的附件設置為固定,而第二張圖片的附件設置為滾動。

          <!DOCTYPE html><html><head><title>background-attachment property</title><style>#example {background-image: url("jtp.png"), url("forest.jpg");height:500px;border:4px solid red;background-position:center;background-repeat:no-repeat;background-attachment:fixed, scroll;}</style></head><body><h1> background-attachment:scroll;</h1><p> If there is no scrollbar on your screen, then try to resize the browser's window to see the effect. </p><p ></p></body></html>

          輸出





          網絡推廣與網站優化公司(網絡優化與推廣專家)作為數字營銷領域的核心服務提供方,其價值在于通過技術手段與策略規劃幫助企業提升線上曝光度、用戶轉化率及品牌影響力。這...

          在當今數字化時代,公司網站已成為企業展示形象、傳遞信息和開展業務的重要平臺。然而,對于許多公司來說,網站建設的價格是一個關鍵考量因素。本文將圍繞“公司網站建設價...

          在當今的數字化時代,企業網站已成為企業展示形象、吸引客戶和開展業務的重要平臺。然而,對于許多中小企業來說,高昂的網站建設費用可能會成為其發展的瓶頸。幸運的是,隨...

          DNF銀錠有什么用?等級40以上的戰士可以在赫頓馬爾廣場加入NPC喬安費瑞諾進入地下城。也可以通過入場券進入地下城。進入地下城后,玩家可以自行選擇基礎護送物資【銅錠】。還可以加上其他地下城獲得的【銅錠】【銀錠】【金錠】。dnf金錠有什么用:用金錠,銀錠等。用金幣換票。加了他們之后,通關后獎勵會更高。f如何獲得鏢局的金元寶:1。根據護送物資的價值獲得不同的獎勵。護送成功后會發放獎勵【護送證書】。其他...

          excle表格如何查找重復姓名?在excel表格中,通過在條件格式中突出顯示單元規則,可以找出重復的名稱。這里以excel 2013版本為例。具體方法如下:1.首先,在電腦上打開要找出重名的Excel表格。2.然后選擇頁面頂部的條件格式。3.接下來,單擊突出顯示單元格規則。4.進入高亮顯示的單元格規則頁面后,選擇復制項目。5.然后在彈出的頁面中選擇【確定】,在excwps怎么搜索人名?在wps表中...

          大白鯊遠控使用教程?云遙控軟件,比大白鯊好。首先,大白鯊的軟件多年沒有更新,肯定會報毒。云遠程控制軟件的生成是免殺戮的,生成服務器可以通過發送給對方來控制。剛出生的大白鯊怎么養?大白鯊繁殖方法:1。大白鯊屬于雜食性動物,攝食以肉食為主,也吃各種小魚、魚、蝦、落蟲、蚯蚓、蝸牛肉等高蛋白飼料。大白鯊需要每天喂食。保持水質新鮮良好,當水質不好時,大白鯊會出現應激狀態,到處碰撞;4。自來水要爆煤氣,只能用...

          TOP
          国产初高中生视频在线观看|亚洲一区中文|久久亚洲欧美国产精品|黄色网站入口免费进人
          1. <nobr id="easjo"><address id="easjo"></address></nobr>

              <track id="easjo"><source id="easjo"></source></track>
              1. 
                

              2. <bdo id="easjo"><optgroup id="easjo"></optgroup></bdo>
              3. <track id="easjo"><source id="easjo"><em id="easjo"></em></source></track><option id="easjo"><span id="easjo"><em id="easjo"></em></span></option>