1

I have the following structure in my code and I cannot change the absolute div or panel div - as it's part of existing code and affects multiple pages.

  1. I need scroll on the relative div and it has to fill the bottom area of the absolute div - So I cannot have height in pixel as it has to match the user screen size.
  2. I can add more divs inside relative div.

http://jsbin.com/wenap/4

   .absolute {
      background-color: #F0F0F0;
      border: 1px solid #000;
      bottom: 0;
      left: 0;
      overflow: hidden;
      position: absolute;
      top: 0;
      width: 300px;
      z-index: 0;
    }
    .panel {
      min-height: 100px;
      max-height: 150px;
      background: #fff;
      display: block;
    }
    .relative {
      overflow: scroll;
    }

 <div class="absolute">  
    <div>
    <div class="panel">MY PANEL - Variable height</div>
      <div class="relative">
        Need scroll here
        <li>A</li>
        <li>A</li>
    ...
      </div>
    </div>
  </div>
1
  • can panel have a fixed height? Commented Jun 15, 2014 at 6:16

2 Answers 2

3

You can do this:

.relative {
  overflow: scroll; 
  position:absolute;
  height:calc(100% - 100px);
  width:100%;
}

DEMO

Sign up to request clarification or add additional context in comments.

1 Comment

This worked for me. Can you describe what's happening?
1

I don't know how to do it in pure CSS. But using the following jquery you can assign height to the relative height dynamically.

$(document).ready(function(){
var winhei = window.innerHeight;
var nonhei = $('.none').height();
var newhei = winhei - nonhei;
$('.relative').height(newhei);
});

FIDDLE DEMO

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.