简体   繁体   English

背景图像 (CSS) 不会出现在网站上

[英]Background Images (CSS) wont show up on site

I have tried everything but my background image wont show up我已经尝试了一切,但我的背景图片不会显示

the image was in images folder图像在图像文件夹中

I have my file linked into CSS我的文件链接到 CSS

<link rel="stylesheet" href="css/style.css">

Also have the following lines on html html 上也有以下几行

<div id="bgImage" class="bgImageClass">
    
    </div>

Meanwhile in style.css同时在style.css

.bgImageClass {

 background-image: url('../images/background.jpg');

}
#bgImage { 
    position:absolute; width:300px; height:250px;
transition: opacity 0.5s;
}

I hope someone can help我希望有人能帮帮忙

Thank you in advance先感谢您

Try these CSS styles to show background image.试试这些 CSS styles 来显示背景图像。

 .bgImageClass { background-image: url('https://dummyimage.com/16:9x1080'); background-size: cover; background-repeat: no-repeat; background-position: center; position:absolute; width:300px; height:250px; transition: opacity 0.5s; }
 <div id="bgImage" class="bgImageClass"></div>

Mix all of those properties in class selector or id selector as follow:class 选择器或 id 选择器中混合所有这些属性,如下所示:

.bgImageClass { 
         background-image: url('../../image/background.jpg'); 
background-size: cover;
background-repeat: no-repeat;
background-position: center;
position:absolute; 
width:300px; 
height:250px; 
transition: opacity 0.5s; 
   }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM