Greg
Greg

Reputation: 3063

DIV position issues

I'm trying to position my DIVs as below

Logo / Menu / Social

Intro-left / intro-right

backpicture

Middle-1

bottom-left / bottom right

The issue is that for the moment DIVs are displayed like this (see JSFiddle http://jsfiddle.net/A4Sn8/1/ ):

Logo / Menu

Social

backpicture

Intro-left / intro-right

Middle-1

bottom-left

bottom right

In summary, my "social" DIV is below the menu instead of on its right. Bottom-right DIV is under bottom-left instead of on its right and backpicture is before Intro-left and intro-right instead of after.

How could I fix this?

Many thanks

HTML

 <div id="logo">Logo</div>  <!-- End DIV Logo -->
  <div id="mainmenu">
    <ul>
      <li>
        <h5>Menu I</h5>
        <ul>
          <li><a title="" href="">Biography</a> </li>
          <li><a title="" href="">Publications</a> </li>
        </ul>
      <li>
        <h5>Menu 2</h5>
        <ul>
          <li><a title="" href="">Demo</a> </li>
          <li><a title="" href="">Features</a> </li>
          <li><a title="" href="">Comparison</a> </li>
        </ul>
      </li>
      <li>
        <h5>Menu 3</h5>
        <ul>
          <li><a title="" href="">Item 1</a> </li>
          <li><a title="" href="">Item 2</a> </li>
          <li><a title="" href="">Item 3</a> </li>
        </ul>
      </li>
      <li>
        <h5>Menu 4</h5>
        <ul>
          <li><a title="" href="">ddfd</a> </li>
          <li><a title="" href="">dsfd</a> </li>
        </ul>
      </li>
    </ul>
  </div>  <!-- End DIV Main Menu -->
 <div id="social">Social</div>

    <div id="intro-left"></div>

    <div id="intro-right">
    <div id="content-headline"><h1>Novitates autem si spem</h1></div>  <!-- End DIV Content headline-->
      <p>Novitates sit.</p>

    </div> 

<div id="backpicture">backpicture</div>
<div id="middle-1">Middle-1</div>
<div id="bottom-left">bottom-left</div>
<div id="bottom-right">bottom-right</div>

CSS:

@charset"UTF-8";
/* CSS Document */

Html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: #fff;
    font-family: 'Open Sans', sans-serif; 
}

#logo {
    position: absolute;
    top: 35px;
    left: 20px;
    color: #000;
    font-size: 20px;
}

/* mainmenu */

#mainmenu {
    margin-top: 35px;
    width: 100%;
    padding-bottom: 10px; 
    overflow: hidden;
}
#mainmenu ul {
    float: right;
    margin: 0;
    color: #000;
    list-style: none;
}
#mainmenu ul li {
    display: inline-block;
    float: left;
    width: 140px;
    line-height: 20px;
}
#mainmenu>ul>li {
    margin-left: 20px;
}
#mainmenu ul li a {
    display: block;
    text-decoration: none;
    font-weight:600;
    font-size: 12px;
}
#mainmenu ul li a, #mainmenu ul ul:hover li a {
    color: #333;
    -webkit-transition-timing-function: ease-out, ease-in, linear, ease-in-out;
    -moz-transition-timing-function: ease-out, ease-in, linear, ease-in-out;
    -ms-transition-timing-function: ease-out, ease-in, linear, ease-in-out;
    -o-transition-timing-function: ease-out, ease-in, linear, ease-in-out;
    transition-timing-function: ease-out, ease-in, linear, ease-in-out;
    -webkit-transition-duration: .4s, .4s, .4s, .4s;
    -moz-transition-duration: .4s, .4s, .4s, .4s;
    -ms-transition-duration: .4s, .4s, .4s, .4s;
    -o-transition-duration: .4s, .4s, .4s, .4s;
    transition-duration: .4s, .4s, .4s, .4s;
    -webkit-transition-property: all, -webkit-transform;
    -moz-transition-property: all, -moz-transform;
    -ms-transition-property: all, -ms-transform;
    -o-transition-property: all, -o-transform;
    transition-property: all, transform;
}
#mainmenu ul ul li a:hover, #mainmenu ul ul li.current-menu-item a {
    color: #005EBC;
    -webkit-transition-timing-function: ease-out, ease-in, linear, ease-in-out;
    -moz-transition-timing-function: ease-out, ease-in, linear, ease-in-out;
    -ms-transition-timing-function: ease-out, ease-in, linear, ease-in-out;
    -o-transition-timing-function: ease-out, ease-in, linear, ease-in-out;
    transition-timing-function: ease-out, ease-in, linear, ease-in-out;
    -webkit-transition-duration: .4s, .4s, .4s, .4s;
    -moz-transition-duration: .4s, .4s, .4s, .4s;
    -ms-transition-duration: .4s, .4s, .4s, .4s;
    -o-transition-duration: .4s, .4s, .4s, .4s;
    transition-duration: .4s, .4s, .4s, .4s;
    -webkit-transition-property: all, -webkit-transform;
    -moz-transition-property: all, -moz-transform;
    -ms-transition-property: all, -ms-transform;
    -o-transition-property: all, -o-transform;
    transition-property: all, transform;
}

social {
    right: 10px;
    Color: blue;
}

p {
    color: #333;
    font-weight:300;
    font-size: 13px;
}
h1 {
    color: #00539E;
    font-size: 30px;
    }



#intro-left {
    float: left;
    width: 35%;
}

#intro-right {
    float: right;
    padding-right: 50px;
    width: 60%;
}
#backpicture {
    height:160px;
    width: 100%;
    background: blue;
}

#middle-1 {
    width: 980px;
    background: #c81919;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

#bottom-left {
    float: left;
    width: 35%;
    background: #5421c2;
}

#bottom-right {
    float: right;
    padding-right: 50px;
    width: 60%;
    background: #2ec4a6;

}

Upvotes: 0

Views: 98

Answers (2)

Umang Mehta
Umang Mehta

Reputation: 1497

For mainmenu and social to be in one line:

#social {
    float:right;
    margin-top: 35px;
    right: 10px;
    color: blue;
}
#mainmenu {
    float:left;
    margin-top: 35px;
    width: 80%;
    padding-bottom: 10px; 
    overflow: hidden;
}

The main issue was width:100% given to #mainmenu. This didnt allowed social block to come to its right. Moreover specifying float:left in #mainmenu and float:right in social did the trick.

One more thing, your social in css didnt had #.

Upvotes: 0

Smamatti
Smamatti

Reputation: 3931

You are mixing CSS rules with absolute pixel sizes and percent. That is not always a good idea.

You might have this problem, because your padding-right of 50px is larger than the remaining 5% of free space.

I'm not sure what you are trying to achieve, but I guess the bottom elements should be on the same height. Try this:

#bottom-right {
    float: right;
    padding-right: 5%; /* you defined 50px instead! */
    width: 60%;
    background: #2ec4a6;
}

Sample: http://jsfiddle.net/A4Sn8/2/

Upvotes: 1

Related Questions