簡體   English   中英

背景圖片未顯示在我的頁面上

[英]The background image isn't showing up on my page

我正在設計一個 Neocities 網站,但在我的某個頁面上沒有顯示背景圖片。 我試過在 HTML 和 CSS 中這樣做,但都不起作用。

[This] ( https://maggssszzz.neocities.org/spitbucket.html ) 是有問題的頁面, 是我要附加的圖像。

我最初嘗試將它放在我的 HTML 的頭部,如下所示:

<style>
      background-image: "url(https://www.google.com/url?sa=i&url=https%3A%2F%2Fpngtree.com%2Ffree-backgrounds-photos%2Fabstract-lines&psig=AOvVaw0DqRellrv87omUXChv5XUF&ust=1670010209669000&source=images&cd=vfe&ved=0CA8QjRxqFwoTCOia0u2x2fsCFQAAAAAdAAAAABAU)";
      </style>

但這沒有做任何事情,所以我想把它放在 CSS 中。我嘗試了這兩種不同的方法,但都沒有用:

.body {
  text-align: center;
  background-image: url(https://us.123rf.com/450wm/leavector/leavector1901/leavector190100001/leavector190100001.jpg?ver=6);
}
.square {
  text-align: center;
  background-color: #16a868;
  
  line-height: 70px;
  width: 400px;
  height: 800px;
  color: #701ba1;
  margin: 20px auto;
}

並嘗試 2:

.body {
  text-align: center;
  
}
.square {
  text-align: center;
  background-color: #16a868;
  background-image: url(https://us.123rf.com/450wm/leavector/leavector1901/leavector190100001/leavector190100001.jpg?ver=6);
  line-height: 70px;
  width: 400px;
  height: 800px;
  color: #701ba1;
  margin: 20px auto;
}

但沒有任何效果。 我做錯了什么?

我修好了:這是工作代碼:

<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="spitbucket.css" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?Family=Raleway">
<title>Spitbucket.com</title>
<style>
  h1, p, h2, ul {font-family: "Raleway", sans-serif}
  body {
    background-image: url(https://us.123rf.com/450wm/leavector/leavector1901/leavector190100001/leavector190100001.jpg?ver=6);
  }
</style>

它工作正常。 請檢查在此處輸入圖像描述

使用此代碼

.square {
text-align: center;
background-color: #16a868;
line-height: 70px;
width: 400px;
height: 800px;
color: #701ba1;
margin: 20px auto;
background-image: url(https://www.imgonline.com.ua/examples/two-tone-blurred-background-1-big.jpg);

}

暫無
暫無

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

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