Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6127661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:32:12+00:00 2026-05-23T16:32:12+00:00

I’m having trouble defining the CSS styles necessary in order to achieve the following

  • 0

I’m having trouble defining the CSS styles necessary in order to achieve the following layout:

enter image description here

Ideally, I’d like to have the left two divs be of width 200px. div#image will always have a height of 100px. However, I would like div#sidebar and div#mainContent to have lower borders which lie on the same horizontal level. Their sizes should be large enough to contain their respective content, which is determined when the page is being served. Hence, the one with more content will cause the other div to extend down to the same distance.

The problem is that with absolute positioning, the div#sidebar and div#mainContent elements don’t seem to acknowledge the flow of their child elements. Perhaps I don’t fully understand absolute positioning. Also, it seems like bad form to use Javascript in order to set the inline style of elements on the page. Is there a way of accomplishing this solely with CSS?

I’ve also tried floating the div#image and div#sidebar, and setting a margin-left property on div#mainContent, but wasn’t able to get it to work…

Any help will be much appreciated!

Andrew

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:32:13+00:00Added an answer on May 23, 2026 at 4:32 pm

    Note: This has been abandoned as “unsolvable”, a reasonable answer is given below, but the original problem question remains without a definite solution.


    JS Fiddle: http://jsfiddle.net/steve/gHrce/

    Does almost everything, may help put you on the right track.

    CSS:

    #img {
      background:green;
      float:left;
      height:100px;
      width:200px;
    }
    
    #sidebar {
      background:red;
      clear:both;
      float:left;
      width:200px;
    }
    
    #mainContent {
      background:yellow;
      margin-left:200px;
    }
    

    HTML:

    <div id='img'>
      IMG
    </div>    
    
    <div id='sidebar'>
      SIDEBAR
      <br />
      <br />
      <br />
    </div>   
    
    <div id='mainContent'>
      MAIN CONTENT
      <br style='clear:both' />
    </div>
    

    That extra <br /> at the bottom forces the height of the main content to whatever the sidebar height is.

    The <br /> tags in the sidebar are just to provide some extra height for demonstration purposes.


    Of course, you can add Javascript pretty easily to expand the sidebar’s height, but it smells strongly of hack:

    if($('mainContent').offsetHeight > $('sidebar').offsetHeight + 100) {        
      $('sidebar').style.height = $('mainContent').offsetHeight - 100 + 'px';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have some data like this: 1 2 3 4 5 9 2 6
I have just tried to save a simple *.rtf file with some websites and
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.