简体   繁体   English

CSS背景图片未显示

[英]CSS background-image not showing

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="css/font-awesome.css">

        <style type="text/css">
            body {
                background-image: url(man_meteor.jpg);
                background-repeat: no-repeat;  
                background-size: cover;
                background-attachment: fixed;
                background-position: center;
            }

Why is my background img not showing? 为什么我的背景img没有显示? Below is how my files are arranged. 以下是我的文件排列方式。 在此处输入图片说明

As you suggest that your content is written inside a file called home.jsp, I suspect you are mapping "/" to one of your servlets which forwards your home.jsp to the client. 当您建议将内容写在一个名为home.jsp的文件中时,我怀疑您正在将“ /”映射到将home.jsp转发到客户端的一个servlet。 This isn't right because this mapping will map every other resources to the same servlet that you use to forward your home.jsp. 这是不对的,因为此映射会将所有其他资源映射到用于转发home.jsp的同一servlet。 The correct mapping is to map "" instead. 正确的映射是映射“”。

One of your blocks in your web.xml should look like this instead: 您的web.xml中的一个块应该看起来像这样:

<servlet-mapping>
    <servlet-name>The name of your servlet that forwards home.jsp</servlet-name>
     <url-pattern></url-pattern>
</servlet-mapping>

Seeing your code i can say that you need to specify height:200px OR height:400px example and next just for safety add double quotes like background-image: url("man_meteor.jpg"); 看到您的代码,我可以说您需要指定height:200px OR height:400px示例,接下来为了安全起见,请添加双引号,例如background-image: url("man_meteor.jpg"); . Try this their are else other ways to get around. 尝试此操作是其他绕行方式。

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

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