简体   繁体   English

HTML未链接到css文件

[英]HTML not linking to css file

Hey I'm working on a really basic page for a cafe I'm starting up. 嘿,我正在为一家即将开业的咖啡馆编写一个非常基本的页面。 I've got code working to randomly select a background image for the page from a pool of photos I've done but when I try to reference a css file in the same directory, the styles are not reflected in the page at all. 我有代码可以从完成的照片池中随机选择页面的背景图像,但是当我尝试引用同一目录中的CSS文件时,样式根本不会反映在页面中。

index.php 的index.php

<?php
  $bg = array('bg1.jpg', 'bg2.jpg', 'bg3.jpg', 'bg4.jpg', 'bg5.jpg', 'bg6.jpg', 'bg7.jpg' ); // array of filenames

  $i = rand(0, count($bg)-1); // generate random number size of the array
  $selectedBg = "$bg[$i]"; // set variable equal to which random filename was chosen
?>
<!DOCTYPE html>
<html lang="en">
<html>
    <head>
        <title>Recharge Cafe</title>
                <link type="text/css" rel="stylesheet" href="stylesheet.css"/>
        <style type="text/css">
            body {
            background: url(images/<?php echo $selectedBg; ?>) no-repeat center center fixed;
            -webkit-background-size: cover;
            -moz-background-size: cover;
            -o-background-size: cover;
            background-size: cover;
            }
        </style>
        <script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-79082509-1', 'auto');
  ga('send', 'pageview');
</script>
    </head>
    <body>
        <p>Recharge Cafe</p>
    </body>
</html>

stylesheet.css stylesheet.css中

html {
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}

p {
    color: FFFFFF;
}

EDIT: If anyone wants to look it is at http://recharge.cafe 编辑:如果有人想看它是在http://recharge.cafe

Actually according to the site you provided, the CSS file has been loaded. 实际上,根据您提供的站点,已经加载了CSS文件。 The reason why you do not see the "Rechage Cafe" text is that you specify an invalid value to the font color. 之所以看不到“ Rechage Cafe”文本,是因为您为字体颜色指定了无效的值。

p {
  color: FFFFFF
}

It not works. 它不起作用。 RGB color should prefixed by one '#' symbol. RGB颜色应以一个“#”符号作为前缀。
It should be: 它应该是:

p {
  color: #FFFFFF
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM