我正在尝试在我的section标记中添加背景图像,但是它不起作用。我已经获取了正确的文件,但仍然在网页上没有任何显示,并且代码与我看到有人在youtube上的代码中编写的代码完全相同,并且有效]
* { padding: 0; margin: 0; } .header { height: 100%; background-image: linear-gradient(rgba(0,0,0,0.6),rgba(0,0,0,0.6)),url(images/taj-mahal.jpg); background-repeat: no-repeat; background-size: cover; background-position: center; background-attachment: fixed; }
<!DOCTYPE html> <html> <head> <title>Visit India</title> <link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"> </head> <body> <section class="header"> <div class="container"> </div> </section> </body> </html>
我正在尝试在我的section标记中添加背景图像,但是它不起作用。我已经获取了正确的文件,但仍然没有在网页中显示任何内容,并且代码与我所看到的完全相同...
[当您有一些容器内容时,将加载背景图像。现在,“。header”部分的高度为零。或者,您可以将高度:100%更改为高度:100vh,以检查显示的背景图像。
用引号引起图像的路径