1

enter image description here

This is the situation:

I have a main div with 2 div parts(red and orange), both have width: 100% and height: 90%. (should be responsive!)

Inside the red div there is a nav bar (top-right-pink), and 3 buttons in the middle.

The aqua div has to be above both red and orange divs.

What is the right way to position everything?

using relative on the red and orange divs doesnt work because of the '%' in the heights.

<div class="main">
    <div class="thedude"></div>
    <div class="first">
            <ul>
                <li> <a href="#"> Clients </a> </li>
                <li> <a href="#"> About Us </a> </li>
                <li> <a href="#"> Contact </a> </li>
                <li class="hasImage"><a href="#"> <img src="logo.png"> </a></li>
            </ul>
            <div class="timages">
                <a href="#"><img src="icon1.png"></a>
                <a href="#"><img src="icon2.png"></a>
                <a href="#"><img src="icon3.png"></a>
            </div>
    </div>

    <div class="second">

    </div>

</div>




*{
    margin: 0;
    padding: 0;
}

body{
    font-size: 100%; 
    font-family: arial;
}

.first{
    width: 100%; 
    height: 90%;
    background-color: #2acecd;
}

.thedude{
    width: 95em;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    position: absolute;
    background-image: url('yellow_creature.png');
    background-repeat: no-repeat;
    background-size: 100%, 100%;
    z-index: 500;
}

.second{
    width: 100%; 
    height: 90%;
    background-color: #f49900;
}

.third{
    width: 100%;
    height: 90%;
    background-color: #fbc00a;
}

.timages{
    margin:0 auto;
    width: 81%;
    padding-top: 23%;
    text-align: center;
    max-width: 62%;
}

.timages img{
    text-align: center;
    max-width: 100%;
}

ul{
    z-index: 540;
    position: absolute;
    right: 0;
    text-transform: uppercase;
}

li{
    float: left;
    padding: 2em 0.5em;
}

li a{
    text-decoration: none;
    color: white;
}

li img{
    max-width: 10em;
}

.hasImage{
    padding: 0.6em 0.5em;
}

http://jsfiddle.net/4z55sjn0/

4
  • Do you want the aqua element fixed? Btw posting some CSS would speed things up ;)
    – U r s u s
    Feb 3, 2015 at 13:29
  • not fixed, i'll add my current css that doesn;t exactly do what I'm trying to get to :( Feb 3, 2015 at 13:30
  • As i know if you want to position the 3 divs in the red one beside the blue one (as the picture indicates). you need to add a div aroundl. like most of the time in html and css you need wrapper divs. those wrapper divs need to have some width on which the divs inside can relate. But its very hard to understand what you did so far. may a fiddle with the css would be nice Feb 3, 2015 at 13:32
  • see fiddle link in the bottom of my main post. and yes, I have a div around the 3 images class="timages" Feb 3, 2015 at 13:34

1 Answer 1

2

Your HTML structure is the main problem.

HTML

<div class="main">
    <div class="thedude">
    <div class="first">

    </div>

    <div class="second">
            <ul>
                <li> <a href="#"> Clients </a> </li>
                <li> <a href="#"> About Us </a> </li>
                <li> <a href="#"> Contact </a> </li>
                <li class="hasImage"><a href="#"> <img src="logo.png"/> </a></li>
            </ul>
            <div class="timages">
                <a href="#"><img src="icon1.png"/></a>
                <a href="#"><img src="icon2.png"/></a>
                <a href="#"><img src="icon3.png"/></a>
            </div>
    </div>

    <div class="third">

    </div>
</div>
</div>

If you want the menu on the orange div you need to move it...inside the orange block!

CSS

    .first {
    width: 30%;
    height: 90%;
    background-color: #2acecd;
    float:left;
    position:absolute;
    top:5%;
    z-index: 999 !important;
}
.thedude {
    width: 95em;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    position: absolute;
    background-image: url('yellow_creature.png');
    background-repeat: no-repeat;
    background-size: 100%, 100%;
    z-index: 500;
}
.second {
    width: 100%;
    height: 90%;
    background-color: #f49900;
    position:relative;
}
.third {
    width: 100%;
    height: 90%;
    background-color: #fbc00a;
}
.timages {
    position: absolute;
    top: 50%;
    width: 100%;
    text-align: center;
}
.timages img {
    text-align: center;
    max-width: 100%;
}
ul {
    z-index: 540;
    position: absolute;
    right: 0;
    text-transform: uppercase;
    list-style: none;
}
li {
    float: left;
    padding: 2em 0.5em;
}
li a {
    text-decoration: none;
    color: white;
}
li img {
    max-width: 10em;
}
.hasImage {
    padding: 0.6em 0.5em;
}

Check the updated fiddle. Is that close to what you're after?

UPDATE (following comments to this answer)

I've swapped the styles to overcome the misunderstanding.

Check updated fiddle.

I hope it helps.

5
  • What? no, I want it in the "first" div :O The aqua image on the side is a div with an image-background Looks like this: i.stack.imgur.com/4QsaG.png Feb 3, 2015 at 13:54
  • 1
    @Hatul Have you changed your mind? Please check your question/code. You said "Inside the red div there is a nav bar (top-right-pink), and 3 buttons in the middle." In your code the first div is aqua, not red (or orange).
    – U r s u s
    Feb 3, 2015 at 13:58
  • no no, please read again: "Inside the red div there is a nav bar (top-right-pink), and 3 buttons in the middle. [enter] The aqua div has to be above both red and orange divs. " Feb 3, 2015 at 13:59
  • it's aqua in the code but in the image example it's the red one. look at the mockup if it's better for you. Sorry for the missunderstanding Feb 3, 2015 at 14:00
  • I'll take a look at it in a sec! (i'll reply and mark as solved.. Thanks :) Feb 3, 2015 at 14:56

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.