CSS div 区域未出现(但在 firebug 中显示?)
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
因为 HTML 元素默认具有透明背景色。为元素指定背景颜色,您可以立即看到它:
请参阅: 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:
See: http://jsfiddle.net/v3yqf/3/ ( http://jsfiddle.net/v3yqf/3/embedded/result if your screen is narrow)
尝试将侧边栏 div 放在内容 div 之前。另外,如果您指定
background: green
而不是color: green
,您会看到更好的效果;)编辑:
因此,使用
而不是
Try placing your sidebar div before your content div. Also, you will see it better if you specify
background: green
instead ofcolor: green
;)Edit:
So, use
instead of