css background-image无法正常工作 [英] css background-image not working properly

查看:160
本文介绍了css background-image无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码:

  body 
{
background-image:url gradient2.png');
}

在w3学校找到它的简单我在同一个文件夹的图片,我一切,我不知道为什么我不能在css插入图像。 html标签正在工作。我有同样的问题3-4个月前,现在再次使用html和仍然,不工作。 pic只是不会显示。



这是我的完整css:

  * 
{
margin:0;
padding:0;
}

body
{
background:url(pagebg2.jpg)repeat left top;
font:normal 10pt Arial,Helvetica,sans-serif;

}

#center {
box-shadow:1px 1px 11px 1px rgba(0,0,0,1)
border:3px solid rgba(0,0,0,0.8);
background-color:#50649d;
border-radius:20px 20px;
width:650px;
height:900px;
margin:0 auto;

}
#pic {
text-align:center;
}
img {
box-shadow:1px 1px 11px 1px rgba(0,0,0,1)
border:3px solid rgba(0,0,0,0.8);
border-radius:20px 20px;
}

这是html:

 <!DOCTYPE html> 
< html>
< head>
< meta http-equiv =Content-Typecontent =text / html; charset = UTF-8>
< link type =text / css =stylesheethref =CSS / btstyle.css>
< title>< / title>
< / head>
< body>
< header>这是标题< / header>
< div id =container>
< div id =picclass =column>


< / div>


< div id =centerclass =column>

center
< / div>
< / div>
< footer class =foot>< p>©WebMaster pr.toma@gmail.com< / p>< / footer>
< / body>
< / html>


解决方案

我测试了它在jsFiddle。问题在于您的图片网址



查看:
jsFiddle链接

  body 
{
background:url(http:// jsfiddle。 net / img / logo.png)repeat left top;
font:normal 10pt Arial,Helvetica,sans-serif;

}

这里,我只更改图像网址。 >

i use exact this code:

body
{
background-image:url('gradient2.png');
}

found on w3 school its simple i got the pic in same folder, i did everything and i dont know why i cant insert images in css. The html tag is working. I had the same problem 3-4 months ago, and now working again with html and still, not working. The pic just wont show.

this is my full css:

*
{
    margin: 0;
    padding: 0; 
}

body
{
        background: url("pagebg2.jpg") repeat left top;    
    font: normal 10pt Arial,Helvetica,sans-serif;

}

#center{
    box-shadow: 1px 1px 11px 1px rgba(0, 0, 0, 1);
    border: 3px solid rgba(0, 0, 0,0.8);
    background-color:#50649d;
    border-radius: 20px 20px;
    width: 650px;
    height:900px;
    margin: 0 auto;

}
#pic {
     text-align:center;
}
img {
    box-shadow: 1px 1px 11px 1px rgba(0, 0, 0, 1);
    border: 3px solid rgba(0, 0, 0,0.8);
    border-radius: 20px 20px;
}

and this is the html:

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link type="text/css" rel="stylesheet" href="CSS/btstyle.css">
        <title></title>
    </head>
    <body>
        <header>this is the title</header>
        <div id="container">
                <div id="pic" class="column">
                <img src="opel.png" />


                </div>


                <div id="center" class="column">

                  center
                </div>
        </div>
        <footer class="foot"><p>©WebMaster pr.toma@gmail.com</p></footer>
    </body>
</html>

解决方案

Your code is perfect. I tested it on jsFiddle. The problem is with your image URL

Check this out: jsFiddle link

body
{
    background: url("http://jsfiddle.net/img/logo.png") repeat left top;    
    font: normal 10pt Arial,Helvetica,sans-serif;

}

Here, i only change the image url.

这篇关于css background-image无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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