簡體   English   中英

如何使本節對背景作出響應?

[英]How do I make this section background responsive?

我試圖使<section>標簽上的背景具有響應性,由於某種原因,當我更改瀏覽器大小時,背景將無法適應。 我的代碼有沖突嗎?

 @import url('https://fonts.googleapis.com/css?family=Questrial'); @import url('https://fonts.googleapis.com/css?family=Roboto+Slab'); @keyframes breath { 0% { background-size: 100% auto; } 50% { background-size: 140% auto; } 100% { background-size: 100% auto; } } #bkg { width: 100%; height: 100%; animation: breath 100s linear infinite; } section { font-size: 35px; text-align: center; color: black; font-weight: ; font-family: 'Questrial', sans-serif; } hr { border-top: 1px solid black; } html, body { height: 100%; min-height: 100%; margin: 0; padding: 0; } .section { position: relative; background-size: cover; background-repeat: no-repeat; margin: 0; padding: 0; height: 100%; width: 100%; } 
 <section style="background-image: url(img/bg.png); background-size: cover;"></section> 

section標簽不會受到.section影響,而class="section"而不是<section>此參考標簽請檢查以下修訂代碼:

 section { position: relative; background-size: cover; background-image: url('https://cdn.pixabay.com/photo/2018/01/24/18/05/background-3104413_960_720.jpg'); background-repeat: no-repeat; font-size: 35px; text-align: center; color: black; font-family: 'Questrial', sans-serif; margin: 0; padding: 0; height: 100%; width: 100%; } 
 <section>Lorem Ipsum</section> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM