简体   繁体   English

CSS背景图片不起作用

[英]CSS background-image doesn't work

I have a problem to visualize (in all browsers) the background-image that I use in the CSS: 我在可视化(在所有浏览器中)在CSS中使用的背景图像时遇到问题:

HTML: HTML:

<div class="container">
    <div class="row" style="margin-top:-5px;">
        <div class="col-xs-1"></div>
        <div class="col-xs-10">
            <div class="box1" style="width:311px; float:left;">
                <div class="markermenu">
                    <ul>
                        <li><a href="#">One</a></li>
                        <li><a href="#">Two</a></li>
                        <li><a href="#">Three</a></li>
                        <li><a href="#">Four</a></li>
                        <li><a href="#">Five</a></li>
                    </ul>
                </div> 
            </div>

CSS: CSS:

.markermenu{
    width: 311px; /*width of menu*/
}

.markermenu ul{
    list-style-type: none;
    margin: 1px 0;
    padding: 0;
    border: 1px solid #9A9A9A;
}

.markermenu ul li a{
    background:url(img/lens.png) no-repeat 2px center;
    height:79px;
    color: #00014e;
    display: block;
    width: auto;
    padding: 30px 0;
    padding-left: 90px;
    text-decoration: none;
    border-bottom: 1px solid #B5B5B5;
}

* html .markermenu ul li a{ 
    width: 150px;
}

.markermenu ul li a:visited, .markermenu ul li a:active{
    color: #00014e;
}

.markermenu ul li a:hover{
    color: black;
    background-color: #ffffcb;
    background-image:url(img/icon/arrow.png); 
    z-index:10;/*onMouseover image change. Remove if none*/
}

The problem is that I don't see the images on background...someone know why..? 问题是我在背景上看不到图像...有人知道为什么..? Thanks so much. 非常感谢。

Resolved. 解决。 Thanks!!! 谢谢!!! Another question...if i wont use a different image for avery voice of the menu (normal and hover) AND if i wont use two image for every voice, how i must modify the html and css??? 另一个问题...如果我不会为菜单的平均声音使用不同的图像(正常和悬停),并且如果我不会为每个声音使用两个图像,那么我必须如何修改html和CSS? thanks so much 非常感谢

You will have to check the path of the background-image in the 您将必须检查背景图片的路径

.markermenu ul li a { }

and

.markermenu ul li a: hover { }

classes. 类。

If you have provided the path correctly then your code should work fine. 如果您正确提供了路径,则您的代码应该可以正常工作。 See this fiddle: 看到这个小提琴:

http://jsfiddle.net/Qy2T2/ http://jsfiddle.net/Qy2T2/

Background - Shorthand Property 背景-简写属性

Format: 格式:

background: <color> url("<image path>") <repeat> <x> <y>;

Example: 例:

body { background: #FFFFFF url("MyImage.png") no-repeat right top; }

Working Example 工作实例

Make sure you check your image path. 确保检查图像路径。

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

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