gpt4 book ai didi

html - 如何在 sidebar-wrapper CSS 类中显示图像

转载 作者:行者123 更新时间:2023-11-28 12:45:42 25 4
gpt4 key购买 nike

我想在#sidebar-wrapper 类中显示图像,我使用以下代码:

CSS:

#sidebar-wrapper {
background-image:url('/images/nav.jpg');
margin-left: -250px;
left: 250px;
width: 250px;
position: fixed;
height: 100%;
overflow-y: auto;
z-index: 1000;
transition: all 0.4s ease 0s;
}

HTML:

 <div id="sidebar-wrapper">
<ul class="sidebar-nav" id="MainMenu">
<li class="sidebar-brand"><a href="#">Menu</a>
</li>
<li><a href="#"><img src="images/icons/home.png">HOME</a>
</li>
<li><a href="#">Menu</a>
<ul class="sidebar-brand">
<li><a href="navigation.html">sub menu 1</a></li>
<li><a href="#">sub menu 2</a></li>
<li><a href="#">sub menu 3</a></li>
<li><a href="#">sub menu 4</a></li>
<li><a href="#">sub menu 5</a></li>
<li><a href="#">sub menu 6</a></li>
</ul>
</li>
<li><a href="#">Menu</a>
</li>
<li><a href="#">Menu</a>
</li>
<li><a href="#">Menu</a>
</li>
<li><a href="#">Menu</a>
</li>
<li><a href="#">Menu</a>
</li>
</ul>
</div>

图像未显示。任何帮助或引用将不胜感激。

问候

最佳答案

尝试使用它,它应该可以正常工作:

#sidebar-wrapper {
background:url(/images/nav.jpg) no-repeat center; // an maybe the quotes are not necessary. Check if the path is correct!
background-size: cover; // change this to 'contain' if you want to test different modes
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
margin-left: -250px;
left: 250px;
width: 250px;
position: fixed;
height: 100%;
overflow-y: auto;
z-index: 1000;
transition: all 0.4s ease 0s;
}

关于html - 如何在 sidebar-wrapper CSS 类中显示图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25178339/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com