如何将控件浮动在图像顶部(使用图像背景)
我的网站页面的整个顶部都有一个徽标图像。徽标本身仅占左侧约三分之一。该条的右侧三分之二是普通的深蓝色。我有几个链接和用户名显示在右侧,并且希望将它们浮动在图像上。
最初,我的图像占据了栏 (div) 左侧的三分之二,还有一个单独的 div,链接位于右侧。问题是该方法在两个 div 之间留下了明显的边界线,即使它们具有相同的颜色。
透明度会有帮助吗?我该如何设置?
_________________________________________________________________ | LOGO HERE User: David Troy | | LOGO HERE Home | FAQ | Contact Us | |_______________________________________________________________|
I have a logo image across the entire top of my website page. The logo itself only takes up about one third of the left hand side. The right two thirds of this bar is plain and dark blue in color. I have several links and the user name displayed on the right side and would like to float those over the image.
Originally, I had the image taking up the left two thirds of the bar (div) and a separate div with my links on the right. The problem is that that method leaves a noticeable boundary line between the two divs even though they are the same color.
Is transparency going to help? How do I set this up?
_________________________________________________________________ | LOGO HERE User: David Troy | | LOGO HERE Home | FAQ | Contact Us | |_______________________________________________________________|
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
关于“细线空间”:如果您使用 Internet Explorer,则必须省略
div
之间的空格,如下所示:我相信这是由于 Quirks 模式造成的;它在 XHTML 严格模式下按预期显示。
然后,CSS 看起来像这样:
Concerning the "hairline space": if you are using Internet Explorer, you will have to omit spaces between the
div
s as follows:This is due to Quirks mode, I believe; it displays as expected in XHTML Strict mode.
Then, the CSS looks like this:
尝试:
假设您的左侧 div 有一个
class="left"
,右侧 div 有一个class="right"
这将消除 div 之间的间距。
try :
Assuming your left div has a
class="left"
and the right one has aclass="right"
That will remove the spacing between the divs.
我对你想要实现的目标有点困惑。
如果您使用浮动,请确保为每个 div 指定宽度。
如果您只想将文本显示在图像上方,那么两个简单的 div 块就可以了。
如果你想让它们并排,这应该可行:
I'm somewhat confused as to what you're trying to accomplish.
If you're using float, then make sure that you're specifying a width to each div.
If you just want the text to be on top of the image, two simple div blocks should work.
If you want them to be side by side, this should work: