CSS 水平导航、IMG 还是 DIV?
我正在开发如下图所示的导航。
整个导航是浏览器窗口的宽度,但项目以设计为中心。
我已经有一段时间没有使用任何代码了,并且很难将它们组合在一起。我应该使用身体图像水平重复,然后将列表放置在需要的位置吗?或者我应该使用 div 跨越浏览器窗口的整个宽度并将列表元素放置在需要的位置吗?
谢谢
I'm working on a navigation like the image below.
The whole nav is the width of the browser window, but the items are centered to the design.
I haven't worked with any code in quite some time now, and am having difficulty getting this together. Should I use a body image to repeat horizontally and then position my list where it needs to be? Or Should I use a div to span the whole width of the browser window and position the list elements where they need to be?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我会选择使用具有简单背景颜色的容器并将菜单放置在其中。
我将为您举一个简单的例子。
更新
这是我刚刚整理的一个简单示例:http://jsfiddle.net/aQTRF /
或者,如果您需要黑色菜单栏延伸到导航的容器之外,则将菜单栏添加为重复主体背景的一部分(如您所述),然后将导航定位在上方可能会更容易顶部。这还允许您在主要内容区域内的菜单栏颜色与外部的菜单栏颜色略有不同。
I'd go with using a container with a simple background colour and positioning the menu inside of that.
I'll whip up a quick example for you.
UPDATE
Here's a quick example I've just put together: http://jsfiddle.net/aQTRF/
Alternatively, if you require the black menubar to extend past the container of the navigation, it may be easier to add the bar as part of a repeating body background (as you've stated) and then position your nav over the top. This would also allow you to have a slightly different shade of menubar within the main content area compared to outside of it.
我建议尽可能使用 HTML 和 CSS 而不是图像。它将使页面加载速度更快。
像这个这样漂亮又简单的东西怎么样?
I would advise using HTML and CSS over images where possible. It will make the page faster to load.
How about something nice and simple like this?
使用无序列表
将您的样式添加到 #nav 作为背景
Use an unordered list
Add your styles to #nav for the background