我正在尝试用 php 开发一个网站。在我的主页上,我使用 include 函数(在 php 中)将其他文件包含在其中。但是当加载主页时,其他文件中的 CSS 都搞砸了。它显示好像根本没有 CSS,所以一切都在彼此之上。当我分别加载文件时,一切正常。
所以在我的 index.php 文件中
//code
include 'toolbar.php';
然后在 toolbar.php 中有
div.fileinputs
{
position: relative;
}
div.fakefile
{
position: absolute;
top:0px;
left:0px;
z-index: 10;
}
.text_computer
{
position: absolute;
top:80px;
left:20px;
z-index: 20;
text-align:center
}
input.file
{
cursor: pointer;
position: relative;
text-align: right;
-moz-opacity:0 ;
filter:alpha(opacity: 0);
opacity: 0;
z-index: 30;
width:317;
height:202;
}
.text_upload
{
position: absolute;
top:6px;
left:80px;
z-index: 20;
text-align:center
}
input.submit
{
cursor: pointer;
position: relative;
text-align: right;
-moz-opacity:0 ;
filter:alpha(opacity: 0);
opacity: 0;
z-index: 30;
width:330;
height:50;
}
//code
<div class="fileinputs">
<input type="file" class="file" name='image'/>
<div class="fakefile">
<img src='red_frame.png' width='330'>
</div>
<div class="text_computer">
<a style='font-family:Arial;color:white;'><font size='6'>Choose a photo from<br> your Computer</font></a>
</div>
</div>
<div class="des_box">
<textarea name='description' cols='38' rows='4' placeholder='Enter a description here...' maxlength='500'></textarea><br>
</div>
<br>
<div class="fileinputs">
<input type="submit" class="submit" value='Upload'>
<div class="fakefile">
<img src='red_frame.png' width='330' height='50'>
</div>
<div class="text_upload">
<a style='font-family:Arial;color:white;'><font size='6'>UPLOAD!!!!</font></a>
</div>
</div>
这不是全部代码,但这是我将其包含在 index.php 中时相互叠加的部分
当我只运行 toolbar.php 时,一切都很好。
有办法解决这个问题吗?
是否有其他类型的问题导致了这种情况?
等等,没关系,我找到了这个<!DOCTYPE html>
在我的 index.php 的顶部并将其删除以查看它是否可以解决问题并且由于某种原因确实如此。我不知道为什么会修复它,但现在一切正常。
最佳答案
我建议不要使用'include',请尝试以下方式-
<?php
.
.
.
?>
<link href="../bootstrap/css/bootstrap-timepicker.min.css" rel="stylesheet"
type="text/css"/>
<?php
.
.
.
?>
关于php - CSS 问题和 PHP 中的 include 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18266158/