简体   繁体   English

建立repeat-x头

[英]build repeat-x header

I have some layout css questions. 我有一些布局CSS问题。 Their more like best practices and whats the most efficient way to build this. 他们更喜欢最佳实践,而最有效的方法是什么。 Let me start with a diagram of what I'm trying to achieve. 让我从我要达到的目标开始。 在此处输入图片说明

This header menu background will be liquid and the buttons inside it will be fixed. 此标题菜单背景将是液体,其内部的按钮将被固定。 So really its made up of a left button independent of the gray style background. 因此,实际上它是由独立于灰色样式背景的左键组成的。 Then 3 or more buttons in the gray style background followed by some icons and a search filed, all within the gray background. 然后,灰色样式背景中的3个或更多按钮,然后是一些图标,并进行了搜索,所有这些都在灰色背景中。 My main issue is getting started with how to achieve the grey background expanding to the browsers width 100% and still having 2 rounded corners at each end. 我的主要问题是如何使灰色背景扩展到浏览器的宽度100%,并且两端仍具有两个圆角,这是我的主要问题。

Here is a pseudo html structure 这是一个伪HTML结构

<div id="menuHeader">
<ul>
    <li class=""><a href="#">home</a></li>
    <li class=""><a href="#">button1</a></li>
    <li class=""><a href="#">button2</a></li>
    <li class=""><a href="#">button3</a></li>
    <li class="tools">
      <div class="icon">icon1</div>
      <div class="icon">icon2</div>
      <div class="icon">icon3</div>
      <div class="search"></div>
    </li>
</ul>

Now the css issue where do I put my repeating background. 现在,css问题是我在哪里放置我的重复背景。 If I put it on the menuHeader as a background image then its going to be one long repeating background graphic with no left and right corners. 如果我将它作为背景图像放在menuHeader上,那么它将是一个长重复的背景图形,没有左右角。 Would I need to setup a div for left right and center. 我是否需要为左右和中间设置一个div。 Then have my gray buttons inside that and my blue home button outside that center div to the left of the left div. 然后在其中的灰色div按钮和在左边的div左边的中心div外部的蓝色home按钮。 Or is there a way to do it where I can use the existing tags I have now and not have to deal with extra empty div markup. 还是有一种方法可以在其中使用我现在拥有的现有标签,而不必处理额外的空div标记。

I'm sorry if I'm not more clear but the main question I think is clear how can I get the background graphic to have rounded corners along with repeating background. 很抱歉,如果我不太清楚,但是我认为的主要问题很清楚,我如何才能使背景图形具有圆角以及重复背景。 Then be able to add my buttons in as background graphics. 然后可以将我的按钮添加为背景图形。

Update: this is not going to be html5 unfortunately 更新:不幸的是,这不会是html5

#menuHeader {
  position: relative;
  width: 100%;
  background: url("bg.png") repeat;/*An image which has a width of 1px is sufficient*/
}
#leftSide, #rightSide{
  position: absolute;
  top: 0;
  width: 20px;/*Whatever width*/
  height: 40px;/*Whatever height*/
}
#leftside{
  background: url("left.png") transparent;
}
#rightside{
  background: url("right.png") transparent;
}

Add this HTML inside the div#menuHeader: 将此HTML添加到div#menuHeader中:

<div id="menuHeader">
  <div id="leftside"></div><div id="rightside"></div><!--This location is chosen, so that the automatic z-indexing causes the background to stay at the background-->
  ....
</div>

Create two images (or one, to reduce server load, and use background-position ). 创建两个图像(或一个图像,以减少服务器负载,并使用background-position )。 If you want to add that blue box, expand the left background-image. 如果要添加该蓝色框,请展开左侧的背景图像。 Make sure that the elements inside the div#menuHeader have a transparent or no background. 确保div#menuHeader内部的元素具有透明或无背景。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM