CSS - UL Background Not Working

核能气质少年 提交于 2019-12-25 08:06:04

问题


For some reason when I try to set a UL background the background doesn't work. It works on my body background but it isn't working for the UL.

I know my image is named correctly. I have quadruple checked that. Here is my code:

HTML

<html>
    <head>
        <title>Header</title>

        <link rel="stylesheet" type="text/css" href="css/Style.css" />
    </head>

    <body>

        <div id="page-wrap">

            <ul id="nav">
                <li><a href="#">Link1</a></li>
            </ul>

            <p>Main</p>

        </div>

    </body>
</html>

CSS

body 
{
    background-image: url('../Images/body-background.jpg');
}

#page-wrap
{
    width:1040px;
    margin: 0 auto;
}

ul#nav
{
    margin: 0 auto;
    width: 1040px; height: 185px;
    background-image: url('../Images/header-logo.jpg');
    background-repeat: no-repeat;
}

From what it seems the UL itself isn't working with the <a> tag. Without it the "Link1" shows up. With it though nothing shows up. Either way the background isn't displaying.

Thanks!


回答1:


http://jsfiddle.net/Z7MzE/2/

Looks like it's working to me.

Quintuple check that image for me.




回答2:


I found a solution. Note that in my case, even placing a background image on a wrapper element was being hidden by the ul for some inexplicable reason.

SOLUTION:

ul{}
ul{background:url('image.jpg');}

Don't ask me why it works, but it does. And it works for ANY element you have this problem with, because it cropped up a few times for me.




回答3:


*yea I'm in idiot. It should work fine, but I wouldn't trust the image names check capitalization too.



来源:https://stackoverflow.com/questions/4754772/css-ul-background-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!