首页 > 解决方案 > 更改背景图像白色 html 和 css

问题描述

我想把这张图片作为背景放在 div 下,其中出现了 GED SALC 但它不起作用.. 虽然我已经尝试过使用 CSS,甚至用这个来强制它:

<body bgcolor="blue" background="images/sfondo.png">

这是代码:

<!DOCTYPE html>
<?php 
	session_start();
    if(!isset($_SESSION["username"])){
    	header('location: ../index.php');
    }else
    {
    
?>
<html>
	<head>
    <title>G.E.D.</title>
		<link href="../paginaIniziale/css/bootstrap-4.0.0.css" rel="stylesheet">
		<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
		<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato">
		<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
		<style>
			.bgimg-1{
				background-attachment: fixed;
				background-position: center;
				background-repeat: no-repeat;
				background-size: cover;
				background-image: url("images/sfondo.png");
				min-height: 100%;
			}
		</style>
	</head>
	<body bgcolor="blue" background="images/sfondo.png">
		<div class="w3-top">
			<div class="w3-bar w3-padding w3-card" style="background-color: #ffc107">
				<h1>G.E.D. - S.A.L.C.</h1>
			</div>			
		</div>
			<div class="w3-display-middle w3-contener" >
				<a class="w3-center w3-padding-large w3-black w3-xlarge w3-wide" style="margin-left: 22px;">Seleziona un operazione</a>
				<div class="w3-center" style="margin-top: 40px;">
					<a href="../pagineHtml/inserimento/inserimentoGenerale/inserimentoCantiere.php" class="w3-bar-item w3-button"><i class="fa fa-home"></i>Milano </a>
					<a href="azioniVisualizza/sceltaCantiere.php" class="w3-bar-item w3-button"><i class="fa fa-home"></i>Roma  </a>
					
				</div>
			</div>
	</body>
</html>
<?php } ?>

这就是图像...背景图像

照片放置在正确的网址中

有谁知道如何帮助我?PS..我承认我用过模板啊哈哈哈

标签: javascripthtmlcssimagebackground-image

解决方案


您创建了一个 CSS 类名称.bgimg-1,但您没有在任何地方使用它。您可能希望<body class="bgimg-1">将 CSS 分配给它。

您还应该确保该文件存在于指定的路径中。您可以通过检查<body>并单击背景 URL 在新选项卡中打开它来在 Chrome 开发工具中找到它。将显示图像,否则您将收到 404 错误。


推荐阅读