不显示背景图片CSS

塞尔吉蒂

这有点令人尴尬,但我被困住了。这是我的index.html:

<header>
    <div class="wrapper">
        <div class="top_menu">
        </div>
    </div>
</header>

这是我的style.css:

body{ 
    font-family: Verdana, Geneva, sans-serif;
    font-size: 12 px;
}
.wrapper{ width:1680 px; margin:0 auto }
header{float:left; width:100%; min-width:1680 px} 

.top_menu{ background-image:url('../images/top_menu.jpg');}

我将<link rel="stylesheet" type="text/css" href="css/style.css">标签包含在索引中。根文件夹包含:index.html,css文件和images文件(root子节点)。你能帮我吗?

JSuar

GolezTrol正确。标头需要一个明确的高度,因为其中没有任何东西top_menu可以赋予它高度。

.top_menu{ 
  background-image:url('https://www.google.com/images/srpr/logo11w.png');
  height: 100px;
}

如果要将背景图像的高度设置为:使用CSS设置背景图像的尺寸?

有关height工作原理的更多信息

height:100% 表示元素将具有其父容器的100%高度。

height:auto 意味着,元素将具有灵活的高度,即其高度将取决于其子元素的高度

上述说明包含的示例:css高度之间的差异:100%与高度:自动之间回答

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章