Search code examples
javascripthtmlcssgoogle-closure-library

CSS style - Placing a div outline inside an scrollable div


I am trying to make a selectable list in Google Closure . I got almost everything , but when i added the scroll functionality to the container. i realized that something is wrong with my style if the outline element

 <div class="Selectable"
        style="height: 400px; overflow-y: scroll" id ="list2">
          <div class="selectable-item">0 </div>
          <div class="selectable-item">1</div>
          .....
          .....
          .....
 <div class="selectable-outline" style="left: 88px; top: 97px; width: 76px; height: 725px; "></div></div>
        </div>

here is the fiddle.

http://jsfiddle.net/dekajp/uC5jm/4/

i want div ( outline ) to be contained within scrollable parent. the scroll height of parent is around 2000. could not figure this out !!

Thanks for you help !!!


Solution

  • The outline element is positioned absolute, therefore you'll need the parent of that element to be position relative so that the outline element won't break containment.

    /* you need to also capitalize selectable */
    .Selectable {
      position: relative;
      /* more styling */
    }
    

    JSFIDDLE