Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 背景图像100%在实例中不工作_Php_Html_Css - Fatal编程技术网

Php 背景图像100%在实例中不工作

Php 背景图像100%在实例中不工作,php,html,css,Php,Html,Css,这适用于我的主页,使图像适合我的背景 <body> <div style="height:100%; background-image:url(location.png); background-size:cover;"> <?php include("homebuttons.php");?> </div> </body> 但他似乎不想在这里工作 <body> <div style="height:100%; b

这适用于我的主页,使图像适合我的背景

<body>
<div style="height:100%; background-image:url(location.png); background-size:cover;">
<?php include("homebuttons.php");?>
</div>
</body>

但他似乎不想在这里工作

<body>
<div style="height:100%; background-image:url(location.png); background-size:cover;">
<div class="navbar">
<?php include("navbar.php"); ?>
</div>
<div id="content">
<?php include("pages/" . $_POST["var"] . ".php"); ?>
</div></div>
</body>

我试着把潜水艇放在不同的位置,但还是没找到。我所需要的只是某一页的背景资料。我计划在完成后使用此代码

<div style="height:100%; background-image:url(<?php echo $_POST["var"] ?>.jpg); background-size:cover;">

问题在于style=“height:100%;在您的div中,当您定义height:100%时,这100%指的是元素父级大小,而不是视口大小。这仅适用于宽度,您需要使用px大小设置最小高度来实现此功能。

由于某些原因,当您

<!DOCTYPE html>


在文档中,这种100%匹配将不起作用。奇怪。

或javascript,我猜即使我将最小高度设置为100%,也不起作用。我只希望该图像填充背景,并根据其啤酒大小确定。