为什么这个BG图像不会显示?

时间:2010-03-01 19:41:03

标签: html css

这是我的HTML:

                <div id="leftMenuWrapper">
                    <div id="ramps" class="leftMenuHeaderButton"></div>
                    <div id="carServiceRamps" class="leftMenuSubButton"></div> <div class="clear"></div>
                    <div id="67RaceRampsXT" class="leftMenuProductButton"></div>
                </div>

这是我的CSS:

#leftMenuWrapper{
background:url(../images/main_elements/leftMenu_BG.jpg) repeat-y;
border:#777777 thin solid;
width:160px;
margin-left:-19px;
position:absolute;
padding-bottom:5px;
}

.leftMenuHeaderButton{
width:175px;
height:35px;
position:relative;
top:-16px;
left:-11px;
}
    #ramps{
    background:url(../images/main_elements/leftMenu/Ramps.png) no-repeat;
    }


.leftMenuSubButton{
width:169px;
height:21px;
position:relative;
float:right;
left:1px;
}
    #carServiceRamps{
    background:url(../images/main_elements/leftMenu/car-service-ramps.png) no-repeat;
    }

.leftMenuProductButton{
width:160px;
height:20px;
clear:both
}

    #67RaceRampsXT{
    background:url(../images/main_elements/leftMenu/67-Race-Ramp-XTs.jpg) no-repeat;
    width:160px;
    height:20px;
    }

.clear{clear:both}

一切正常,除了<div id="67RaceRampsXT" class="leftMenuProductButton"></div>不会显示它的BG图像(它甚至不会显示BG颜色)。元素在那里,因为如果我调整大小,它会相应地调整,但它不会在FF或Chrome中显示图像。

我可以在其中放置<IMG>没问题,我甚至可以将BG分配给.leftMenuProductButton但不分配给#67RaceRampsXT

2 个答案:

答案 0 :(得分:6)

我认为id不能以数字开头。尝试将您的id更改为类似RaceRamps67XT的内容并按照这种方式进行测试 - 在HTML和CSS中查看它的作用。

答案 1 :(得分:2)

非常确定只有类标识符才能以数字开头。对于您想要的ID [A-Za-z_]。尝试将您的ID更改为#sixtySevenRaceRampsXT。有关更多信息,请查看有关有效ID的此问题:

What are valid values for the id attribute in HTML?