CSS div 区域未出现(但在 firebug 中显示?)

发布于 2024-10-09 21:12:00 字数 357 浏览 0 评论 0原文

我有一个 div (class="sidebar"),我想将其显示在内容区域的右侧。我将内容区域设置为容器,然后将侧边栏放置在其中,指定高度、宽度、背景颜色并将其向右浮动。

它显示在萤火虫中,但没有出现在屏幕上。

我目前正在学习 CSS,所以欢迎任何关于我所缺少的内容的提示/建议。

如有任何建议,我们将不胜感激。

提前致谢,

汤姆·珀金斯(Tom Perkins)

您可以在此处查看我的代码: http://jsfiddle.net/tomperkins/v3yqf/

I have a div (class="sidebar") that I want to display on the right hand side of my content area. I've set the content area as the container, then placed the sidebar inside that, specified height, width, background color and floated it right.

It's displaying in firebug, but not appearing on the screen.

I'm currently learning CSS so any tips/advice on what I'm missing are welcome.

Any advice available will be gratefully received.

Thanks in advance,

Tom Perkins

You can view my code here:
http://jsfiddle.net/tomperkins/v3yqf/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

許願樹丅啲祈禱 2024-10-16 21:12:00

因为 HTML 元素默认具有透明背景色。为元素指定背景颜色,您可以立即看到它:

.sidebar {
    background: orange;
}

请参阅: http://jsfiddle.net/v3yqf/3 / ( http://jsfiddle.net/v3yqf/3/embedded/result 如果您的屏幕很窄)

Because HTML elements have transparent background color by default. Giving the element a background color and you can see it immediately:

.sidebar {
    background: orange;
}

See: http://jsfiddle.net/v3yqf/3/ ( http://jsfiddle.net/v3yqf/3/embedded/result if your screen is narrow)

虚拟世界 2024-10-16 21:12:00

尝试将侧边栏 div 放在内容 div 之前。另外,如果您指定 background: green 而不是 color: green ,您会看到更好的效果;)

编辑:

因此,使用

<div class="sidebar"></div>
<div class="content"></div>

而不是

<div class="content"></div>
<div class="sidebar"></div>

Try placing your sidebar div before your content div. Also, you will see it better if you specify background: green instead of color: green ;)

Edit:

So, use

<div class="sidebar"></div>
<div class="content"></div>

instead of

<div class="content"></div>
<div class="sidebar"></div>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文