1

HTML

Sorted it for seo

<div class="content">Content</div>
<div class="nav1">
  <ul>
  <li>nav 1</li>
  <li>nav 2</li>
  <li>nav 3</li>
  </ul>
</div>    
<div class="nav2">
  <ul>
    <li>item 1</li>
    <li>item 2</li>
  </ul>
</div>

CSS

.nav1 {
    width:100px;
    float:left;
}
.nav2 {
    width:100px;
    float:right;
}
.content {
    width:100%;
    float:right;
    background:#09F;
}

the numbering:

1: content

2: nav1

3: nav2

4: container

I want something like that;

https://i.sstatic.net/AH5OR.jpg

But the result is bad.

https://i.sstatic.net/ypCft.jpg

4
  • Are you sure your images are the right way around there? Which is your desired result? Commented Feb 26, 2011 at 16:18
  • put nav1 and nav2 inside content. Commented Feb 26, 2011 at 16:39
  • @n0rd I moved, but remained above Commented Feb 26, 2011 at 17:18
  • @n0rd to be working BUT, looks different in the browser link Commented Feb 26, 2011 at 17:31

3 Answers 3

4

Live Demo

This will work as it is, providing the content will be higher than the menus. If that's not the case, then you can adjust the min-height value on .content. You should set it to the height of your highest menu.

HTML:

<div id="container">
    <div class="content">Content<br />Content<br />Content<br />Content<br />Content<br />Content<br /></div>

    <div class="nav1">
        <ul>
            <li>nav 1</li>
            <li>nav 2</li>
            <li>nav 3</li>
        </ul>
    </div>

    <div class="nav2">
        <ul>
            <li>item 1</li>
            <li>item 2</li>
        </ul>
    </div>

    <div id="footer">footer</div>
</div>

CSS:

#container {
    width: 80%;
    margin: 0 auto;
    position: relative
}
.nav1 {
    width: 100px;
    position: absolute;
    top: 0;
    left: 0;
    background: #ccc
}
.nav2 {
    width: 100px;
    position: absolute;
    top: 0;
    right: 0;
    background: #ccc
}
.content {
    margin-left: 100px;
    margin-right: 100px;
    background: #09f;
    min-height: 200px
}
#footer {
    background: #999
}
Sign up to request clarification or add additional context in comments.

5 Comments

I already addressed that. You should add a min-height to .content. Like this: jsfiddle.net/Mnbz2/2 - I changed the min-height to 340px. I know this isn't perfect, but it should be viable. Do you really have such a dynamic, changing menu that you can't just stick min-height: 400px or something? Also, how many pages will your highly SEO optimized site have with that little content? Content is the most important thing for SEO :)
This menu(nav1) is dynamic. There are sometimes 10, sometimes 30 items these areas is variable: nav's, content, footer
You could fix it easily with a little jQuery, would that be acceptable?
I have no idea what you meant in that last comment.
@thirtydot Thank you. I did with jQuery
0

html: <div class="container">container</div>

css: .container { width:100%; float:right; border:1px solid; clear:both; }

example:

<html>
<head>
<style>
.nav1 {
    width:100px;
    float:left;
    border:1px solid;
}
.nav2 {
    width:100px;
    float:right;
    border:1px solid;
}
.content {
    width:100%;
    float:right;
    background:#09F;
}
.container {
    width:100%;
    float:right;
    border:1px solid;
    clear:both;
}
</style>
</head>
<body>
<div class="content">Content</div>

<div class="nav1">
<ul>
<li>nav 1</li>
<li>nav 2</li>
<li>nav 3</li>
</ul>
</div>

<div class="nav2">
<ul>
<li>item 1</li>
<li>item 2</li>
</ul>
</div>

<div class="container">container</div>

</body>

Comments

0

The easiest way to achieve your desired layout may be to wrap your nav divs into your content div. You're not getting the exact layout (the content div is not just in teh center but is spread to the whole width), but its a sollution as flexible as possible

  <div class="content">Content
    <div class="nav1">
      <ul>
      <li>nav 1</li>
      <li>nav 2</li>
      <li>nav 3</li>
      </ul>
    </div>    
    <div class="nav2">
      <ul>
        <li>item 1</li>
        <li>item 2</li>
      </ul>
    </div>
  </div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.