【发布时间】:2020-03-29 21:44:31
【问题描述】:
以下 base.html 代码未从同一文件夹中的 css 文件实现渐变背景。
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:
body {
background: linear-gradient(to bottom, #faaca8, #ddd6f3);
background-repeat: no-repeat;
background-size: cover;
width: 100%;
height: 100%;
}
【问题讨论】:
-
如果在同一个文件夹,为什么href没有设置为./style.css?
-
你的意思是它根本不起作用?或者只是没有像你想要的那样覆盖整个页面?
-
将您的
link更改为<link rel="stylesheet" text="text/css" href="style.css">- 您当前正尝试从当前位置进入文件夹 /templates,这显然没有意义,因为 css 在当前文件夹中. -
检查你的css路径。
标签: html css background-image gradient css-gradients