簡體   English   中英

沒有在 CSS 中重復背景圖像不起作用

[英]NO Repeat of Background Image in CSS not working

我今天剛嘗試制作一個網頁並遇到了問題,到處尋找解決問題的方法,但沒有幫助,請告訴我我做錯了什么。

這是 HTML 文檔

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Astrology</title>
  <link rel="stylesheet" type="text/css" href="styles.css">
  
</head>
<body>
  <div class="mtl">
  </div> 
</body>
</html>

這是style.css

*
{
  margin: 0;
  padding: 0;
  background-color: wheat;
  background-size: cover;
}
*.mtl
{
  
  height: 100vh;
  background-image: url("./images/mars_p.jpg");
  background-repeat: no-repeat;
  background-position: -1844px 1160px;
  

}

這是我放置background-repeat: no-repeat;時的圖片background-repeat: no-repeat;

在此處輸入圖片說明

這是去除background-repeat: no-repeat;后的圖片background-repeat: no-repeat;

在此處輸入圖片說明

告訴我為什么這個不重復不起作用

background-repeat: no-repeat; 工作正常,問題出在這一行:

background-position: -1844px 1160px;

圖片移動到屏幕左下角太遠而無法看到。 您只能在將圖像設置為重復或將background-position屬性固定較小時才能看到它。

暫無
暫無

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

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