CSS的背景在Base.html中不起作用 [英] Background from CSS not working in Base.html

查看:55
本文介绍了CSS的背景在Base.html中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下base.html代码未实现同一文件夹中css文件中的渐变背景.

The following base.html code is not implementing the gradient background from the css file that is in the same folder.

base.html:

base.html:

<!doctype html>
<html lang="en">
  <head>
    <link rel="stylesheet" text="text/css" href="templates/css/style.css">
  </head>

<body>
<h1>hi</h1>
</body>
</html>

style.css:

style.css:

body {
background: linear-gradient(to bottom, #faaca8, #ddd6f3);
background-repeat: no-repeat;
background-size: cover;
width: 100%;
height: 100%;

}

推荐答案

如果这不起作用,则问题将是您所指向的目录与style.css文件夹所需要的目录不同.如果在同一文件夹中,请将链接中的href更改为 href ="style.css" .

If this is not working, the problem is going to be the fact that you are referring to a different directory than you are wanting for the style.css folder. If it's in the same folder, please change the href in the link to href="style.css".

这假设您有一个包含base.html的文件夹,并且在SAME文件夹中,还有style.css样式表.

This is assuming you have one folder with the base.html and in the SAME folder, there is also the style.css stylesheet .

如果它基于根目录,则应使用/style.css 或之前的文件夹 ../foldername/style.css .有关更多信息,请在此处阅读.

If it's based on the root directory, you would use /style.css , or on the folder before, ../foldername/style.css. For more, read here.

这篇关于CSS的背景在Base.html中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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