CSS不能使用PHP脚本 [英] CSS not working with PHP script

查看:178
本文介绍了CSS不能使用PHP脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我遵循本教程制作PHP日历



http://www.youtube.com/watch?v=l76uglZBjpk



我有三个文件



show_calendar.php

 <!DOCTYPE html& 
< html>
< head>
< link href =calCss.css =stylesheettype =text / cssmedia =all/>
< / head>
< body>
<?php include(calendar_start.php); ?>
< / body>
< / html>

日历start.php

 <?php 
// $ showmonth = $ _POST ['showmonth'];
/ / showyear = $ _POST ['showyear'];
$ showmonth = 11;
$ showyear = 2012;

$ day_count = cal_days_in_month(CAL_GREGORIAN,$ showmonth,$ showyear);
$ pre_days = date('w',mktime(0,0,0,$ showmonth,1,$ showyear));
$ post_days =(6 - (date('w',mktime(0,0,0,$ showmonth,$ day_count,$ showyear)))

echo'< div id =calendar_wrap>';
echo'< div class =title_bar>';
echo'< div class =previous_month>< / div>';
echo'div class =show_month>'。 $ showmonth。 '/'。 $ showyear。 '< / div>';
echo'< div class =next_month>< / div>';
echo'< / div>';
echo'< div class =week_days>';
echo'< div class =days_of_the_week> Sun< / div>';
echo'< div class =days_of_the_week>星期一< / div>';
echo'< div class =days_of_the_week> Tue< / div>';
echo'< div class =days_of_the_week> Wed< / div>';
echo'< div class =days_of_the_week> Thur< / div>';
echo'< div class =days_of_the_week> Fri< / div>';
echo'< div class =days_of_the_week> Sat< / div>';
echo'< div class =clear>< / div>';
echo'< / div>';

/ *上个月填充天* /
if($ pre_days!= 0){
for($ i = 1; $ i <= pre_days; $ i ++) {
echo'< div class =non_cal_day>< / div>';
}
}

/ *本月* /
($ i = 1; $ i <= $ day_count; $ i ++){
echo'< div class =cal_day>';
echo'< div class =day_heading>'。 $ i。 '< / div>';
echo'< / div>';

}
/ *下一个月填充日* /
if($ post_days!= 0){
for($ i = 1; $ i <= $ post_days; $ i ++){
echo'< div class =non_cal_day>< / div>';
}
}
echo'< / div>';
?>

和css档案calCss.css

  #calendar_wrap {
width:924px;
margin-left:auto;
margin-right:auto;
overflow:hidden;
}
.title_bar {
width:100%;
height:30px;
}
.previous_month {
float:left;
width:308px;
height:30px;
text-align:left;
}
.show_month {
float:left;
width:308px;
height:30px;
text-align:center;
}
.next_month {
float:left;
width:308px;
height:30px;
text-align:right;
}
.week_days {
width:100%;
}
.days_of_week {
float:left;
width:14%;
text-align:center;
}
.cal_day {
position:relative;
float:left;
margin-right:4px;
margin-bottom:4px;
width:128px;
height:95px;
background-color:#9C9;
}
.day_heading {
position:relative;
float:left;
width:40px;
height:16px;
padding:6px;
color:#000;
font-family:Arial;
font-size:14px;
}
.openings {
width:100%;
clear:left;
text-align:center;
}
.non_cal_day {
position:relative;
float:left;
margin-right:4px;
margin-bottom:4px;
width:128px;
height:95px;
background-color:#CCC;
}

.clear {
clear:both;
}

我的问题是show_calendar.php没有显示任何css的一周和数字在一个月。我不知道我可以做错了,有没有任何想法? Im使用xampp本地服务器查看php文件。感谢

解决方案

我已经检查过一切,发现没有理由这不应该工作。可能您的css文件无法加载。你应该检查你的浏览器控制台说什么。



这样可以调试此问题:




  • 您的浏览器

  • shift + strg + j 启动开发人员工具(如果您有IE,此快捷方式适用于Forefox和Chrome f12)

  • 选择控制台

  • 检查您的css是否有加载错误



    <如果你在windows上,那么第二个问题源可能是隐藏的文件扩展名。也许您的档案名称不是 calCss.css ,但 calCss.css.txt 或simmilar。这只是一个猜测,但我以前有这种类型的问题。如果它适用于您的问题 这是如何显示隐藏文件扩展名



Hello i am following this tutorial to make a php calendar

http://www.youtube.com/watch?v=l76uglZBjpk

I have three files

show_calendar.php

 <!DOCTYPE html>
<html>
<head>
<link href="calCss.css" rel="stylesheet" type="text/css" media="all" />
</head>
<body>
<?php include ("calendar_start.php"); ?>
</body>
</html>

calendar start.php

<?php
//$showmonth = $_POST['showmonth'];
//$showyear = $_POST['showyear'];
$showmonth = 11;
$showyear = 2012;

$day_count = cal_days_in_month(CAL_GREGORIAN, $showmonth, $showyear);
$pre_days = date('w', mktime(0,0,0, $showmonth, 1, $showyear));
$post_days = (6 - (date('w', mktime(0,0,0, $showmonth, $day_count,$showyear))));

echo '<div id="calendar_wrap">';
echo '<div class="title_bar">';
echo '<div class="previous_month"></div>';
echo 'div class="show_month">' . $showmonth . '/' . $showyear . '</div>';
echo '<div class="next_month"></div>';
echo '</div>';
echo '<div class="week_days">';
echo '<div class="days_of_the_week">Sun</div>';
echo '<div class="days_of_the_week">Mon</div>';
echo '<div class="days_of_the_week">Tue</div>';
echo '<div class="days_of_the_week">Wed</div>';
echo '<div class="days_of_the_week">Thur</div>';
echo '<div class="days_of_the_week">Fri</div>';
echo '<div class="days_of_the_week">Sat</div>';
echo '<div class="clear"></div>';
echo '</div>';

/* Previous Month Filler Days */
if ($pre_days != 0) {
for($i = 1 ; $i<=$pre_days;$i++) {
    echo '<div class="non_cal_day"></div>';
}
}

/* Current Month */
for($i=1; $i<= $day_count; $i++) {
echo '<div class="cal_day">';
echo '<div class="day_heading">' . $i . '</div>';
echo '</div>';

}
/* Next Month Filler Days */
if ($post_days != 0) {
for ($i=1; $i<=$post_days; $i++) {
     echo '<div class="non_cal_day"></div>';
}
}
echo '</div>';
?>

and the css file calCss.css

#calendar_wrap {
width: 924px;
margin-left: auto;
margin-right: auto;
overflow: hidden;
}
.title_bar {
width: 100%; 
height: 30px;
}
.previous_month {
float: left;
width: 308px;
height: 30px;
text-align: left;
}
.show_month {
float: left;
width: 308px;
height: 30px;
text-align: center;
}
.next_month {
float: left;
width: 308px;
height: 30px;
text-align: right;
}
.week_days {
width: 100%;
}       
.days_of_week  {
float: left;
width: 14%;
text-align: center;
}      
.cal_day {
position: relative;
float: left;
margin-right: 4px;
margin-bottom: 4px;
width: 128px;
height: 95px;
background-color: #9C9;
}
.day_heading {
position: relative;
float: left;
width: 40px;
height: 16px;
padding: 6px;
color: #000;
font-family: Arial;
font-size: 14px;
}    
.openings {
width: 100%;
clear:left;
text-align: center;
}
.non_cal_day {
position: relative;
float: left;
margin-right: 4px;
margin-bottom: 4px;
width: 128px;
height: 95px;
background-color: #CCC;
}

.clear {
clear: both;
}

my problem is show_calendar.php is not showing any css only text of the days of teh week and numbers in the month. Im not sure what i could be doing wrong, does anyone have any ideas? Im using xampp local server to view the php file. Thanks

解决方案

I've checked everything and found no reason why this shouldn't work. Probably your css file could not be loaded. You should check what you browser console says.

This is how you can debug this problem:

  • start the script in your browser
  • press shift + strg + j to start the developer tools (this shortcut works vor Forefox and Chrome f12 if you got IE)
  • select 'console'
  • check if there is an a loading error for your css

    If you're on windows then the second problem source could be hidden file extensions. Maybe your filename isn't calCss.css but calCss.css.txt or simmilar. This is only a guess but I had this type of problem before. If it applies to your problem this is how you can display hidden file extensions

这篇关于CSS不能使用PHP脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆