首页 > 解决方案 > 页面正在加载而不渲染 style.css

问题描述

这是我的项目目录

样式.css

在内容和

图像.jpg

在图像下

在此处输入图像描述

Login.aspx 页面是默认页面。

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="LoginDemo.Login" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

    <link href="~/Content/style.css" rel="stylesheet" type="text/css" media="screen" runat="server" />

    <title>LOGIN</title>

</head>
<body>
</body>
</html>

这是CSS

*{
    margin:0px;
    padding:0px;
}

body{
    background-image:url(Images/image.jpg);
    background-size:cover;
    background-attachment:fixed;
    font-family:Times New Roman ;
}

页面加载成功,但没有加载背景图片。请帮我。我阅读了不同的文章,并按照建议的解决方案执行了相同的步骤,但仍然存在问题。

标签: c#cssasp.netwebforms

解决方案


图像不在内容文件夹中。所以在你的css中,你应该返回一个文件夹:

  background-image:url(../Images/image.jpg);

注意../路径中之前的Images文件夹


推荐阅读