Padding not applied correctly to div element












1















Inside an overlay I added a scroll-view. Everything is working fine until I try to add a padding to the scroll-view. The top and left padding are correctly applied but the text inside the scroll view exceeds on the right and in the bottom. This is my code






document.addEventListener("keydown", keyDownTextField, false);
this.title_element = jQuery('.scrollviewwrapper', this.$el);

this.title_element.html('<ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> <ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> ');

function keyDownTextField(e) {
alert(document.getElementById('scrollviewwrapper').scrollTop);
var keyCode = e.keyCode;

if (keyCode == 38) {
// up arrow

} else if (keyCode == 40) {
// down arrow
}
}

.overlay {
position: absolute;
background: red;
height: 200px;
width: 500px;
top: 50px;
left: 20px;
bottom: 50px;
z-index: 100;
}

.scrollviewwrapper {
position: relative;
height: 200px;
width: 500px;
padding-top: 30px;
padding-left: 30px;
padding-right: 30px;
padding-bottom: 30px;
overflow: auto;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<html>

<body>
<div class="overlay">
<div class="scrollviewwrapper" id="scrollviewwrapper">
test
</div>
</div>
</body>

</html>












share|improve this question





























    1















    Inside an overlay I added a scroll-view. Everything is working fine until I try to add a padding to the scroll-view. The top and left padding are correctly applied but the text inside the scroll view exceeds on the right and in the bottom. This is my code






    document.addEventListener("keydown", keyDownTextField, false);
    this.title_element = jQuery('.scrollviewwrapper', this.$el);

    this.title_element.html('<ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> <ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> ');

    function keyDownTextField(e) {
    alert(document.getElementById('scrollviewwrapper').scrollTop);
    var keyCode = e.keyCode;

    if (keyCode == 38) {
    // up arrow

    } else if (keyCode == 40) {
    // down arrow
    }
    }

    .overlay {
    position: absolute;
    background: red;
    height: 200px;
    width: 500px;
    top: 50px;
    left: 20px;
    bottom: 50px;
    z-index: 100;
    }

    .scrollviewwrapper {
    position: relative;
    height: 200px;
    width: 500px;
    padding-top: 30px;
    padding-left: 30px;
    padding-right: 30px;
    padding-bottom: 30px;
    overflow: auto;
    }

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
    <html>

    <body>
    <div class="overlay">
    <div class="scrollviewwrapper" id="scrollviewwrapper">
    test
    </div>
    </div>
    </body>

    </html>












    share|improve this question



























      1












      1








      1








      Inside an overlay I added a scroll-view. Everything is working fine until I try to add a padding to the scroll-view. The top and left padding are correctly applied but the text inside the scroll view exceeds on the right and in the bottom. This is my code






      document.addEventListener("keydown", keyDownTextField, false);
      this.title_element = jQuery('.scrollviewwrapper', this.$el);

      this.title_element.html('<ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> <ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> ');

      function keyDownTextField(e) {
      alert(document.getElementById('scrollviewwrapper').scrollTop);
      var keyCode = e.keyCode;

      if (keyCode == 38) {
      // up arrow

      } else if (keyCode == 40) {
      // down arrow
      }
      }

      .overlay {
      position: absolute;
      background: red;
      height: 200px;
      width: 500px;
      top: 50px;
      left: 20px;
      bottom: 50px;
      z-index: 100;
      }

      .scrollviewwrapper {
      position: relative;
      height: 200px;
      width: 500px;
      padding-top: 30px;
      padding-left: 30px;
      padding-right: 30px;
      padding-bottom: 30px;
      overflow: auto;
      }

      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
      <html>

      <body>
      <div class="overlay">
      <div class="scrollviewwrapper" id="scrollviewwrapper">
      test
      </div>
      </div>
      </body>

      </html>












      share|improve this question
















      Inside an overlay I added a scroll-view. Everything is working fine until I try to add a padding to the scroll-view. The top and left padding are correctly applied but the text inside the scroll view exceeds on the right and in the bottom. This is my code






      document.addEventListener("keydown", keyDownTextField, false);
      this.title_element = jQuery('.scrollviewwrapper', this.$el);

      this.title_element.html('<ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> <ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> ');

      function keyDownTextField(e) {
      alert(document.getElementById('scrollviewwrapper').scrollTop);
      var keyCode = e.keyCode;

      if (keyCode == 38) {
      // up arrow

      } else if (keyCode == 40) {
      // down arrow
      }
      }

      .overlay {
      position: absolute;
      background: red;
      height: 200px;
      width: 500px;
      top: 50px;
      left: 20px;
      bottom: 50px;
      z-index: 100;
      }

      .scrollviewwrapper {
      position: relative;
      height: 200px;
      width: 500px;
      padding-top: 30px;
      padding-left: 30px;
      padding-right: 30px;
      padding-bottom: 30px;
      overflow: auto;
      }

      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
      <html>

      <body>
      <div class="overlay">
      <div class="scrollviewwrapper" id="scrollviewwrapper">
      test
      </div>
      </div>
      </body>

      </html>








      document.addEventListener("keydown", keyDownTextField, false);
      this.title_element = jQuery('.scrollviewwrapper', this.$el);

      this.title_element.html('<ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> <ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> ');

      function keyDownTextField(e) {
      alert(document.getElementById('scrollviewwrapper').scrollTop);
      var keyCode = e.keyCode;

      if (keyCode == 38) {
      // up arrow

      } else if (keyCode == 40) {
      // down arrow
      }
      }

      .overlay {
      position: absolute;
      background: red;
      height: 200px;
      width: 500px;
      top: 50px;
      left: 20px;
      bottom: 50px;
      z-index: 100;
      }

      .scrollviewwrapper {
      position: relative;
      height: 200px;
      width: 500px;
      padding-top: 30px;
      padding-left: 30px;
      padding-right: 30px;
      padding-bottom: 30px;
      overflow: auto;
      }

      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
      <html>

      <body>
      <div class="overlay">
      <div class="scrollviewwrapper" id="scrollviewwrapper">
      test
      </div>
      </div>
      </body>

      </html>





      document.addEventListener("keydown", keyDownTextField, false);
      this.title_element = jQuery('.scrollviewwrapper', this.$el);

      this.title_element.html('<ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> <ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> ');

      function keyDownTextField(e) {
      alert(document.getElementById('scrollviewwrapper').scrollTop);
      var keyCode = e.keyCode;

      if (keyCode == 38) {
      // up arrow

      } else if (keyCode == 40) {
      // down arrow
      }
      }

      .overlay {
      position: absolute;
      background: red;
      height: 200px;
      width: 500px;
      top: 50px;
      left: 20px;
      bottom: 50px;
      z-index: 100;
      }

      .scrollviewwrapper {
      position: relative;
      height: 200px;
      width: 500px;
      padding-top: 30px;
      padding-left: 30px;
      padding-right: 30px;
      padding-bottom: 30px;
      overflow: auto;
      }

      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
      <html>

      <body>
      <div class="overlay">
      <div class="scrollviewwrapper" id="scrollviewwrapper">
      test
      </div>
      </div>
      </body>

      </html>






      html css






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 21 '18 at 11:25









      Pete

      41.7k1877120




      41.7k1877120










      asked Nov 21 '18 at 11:17









      koobecafkoobecaf

      82




      82
























          3 Answers
          3






          active

          oldest

          votes


















          0














          Swap your absolute positioning around so your scroll view wrapper is inside the background:






          document.addEventListener("keydown", keyDownTextField, false);
          this.title_element = jQuery('.scrollviewwrapper', this.$el);

          this.title_element.html('<ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> <ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> ');

          function keyDownTextField(e) {
          alert(document.getElementById('scrollviewwrapper').scrollTop);
          var keyCode = e.keyCode;

          if (keyCode == 38) {
          // up arrow

          } else if (keyCode == 40) {
          // down arrow
          }
          }

          .overlay {
          position: relative;
          background: red;
          height: 200px;
          width: 500px;
          top: 50px;
          left: 20px;
          bottom: 50px;
          z-index: 100;
          }

          .scrollviewwrapper {
          position: absolute;
          top: 0; /* use all 4 co-ordinates instead of width and height so it fills the container */
          left: 0;
          right: 0;
          bottom: 0;
          padding: 30px; /* this is shorthand and will apply padding to all 4 sides */
          overflow: auto;
          }

          <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
          <html>

          <body>
          <div class="overlay">
          <div class="scrollviewwrapper" id="scrollviewwrapper">
          test
          </div>
          </div>
          </body>

          </html>








          share|improve this answer

































            1














            Add box-sizing:border-box; rule to your .scrollviewwrapper class:






            document.addEventListener("keydown", keyDownTextField, false);
            this.title_element = jQuery('.scrollviewwrapper', this.$el);

            this.title_element.html('<ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> <ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> ');

            function keyDownTextField(e) {
            alert(document.getElementById('scrollviewwrapper').scrollTop);
            var keyCode = e.keyCode;

            if(keyCode==38) {
            // up arrow

            } else if(keyCode==40) {
            // down arrow
            }
            }

            .overlay{
            position: absolute;
            background: red;
            height: 200px;
            width: 500px;
            top: 50px;
            left: 20px;
            bottom : 50px;
            z-index: 100;
            }

            .scrollviewwrapper{
            position: relative;
            height: 200px;
            width: 500px;
            padding-top: 30px;
            padding-left: 30px;
            padding-right: 30px;
            padding-bottom: 30px;
            overflow:auto;
            box-sizing:border-box;
            }

            <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
            <html>
            <body>
            <div class="overlay">
            <div class="scrollviewwrapper" id="scrollviewwrapper">
            test
            </div>
            </div>
            </body>
            </html>








            share|improve this answer































              0














              you need to add the background: red; to your .scrollviewwrapper class:






              document.addEventListener("keydown", keyDownTextField, false);
              this.title_element = jQuery('.scrollviewwrapper', this.$el);

              this.title_element.html('<ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> <ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> ');

              function keyDownTextField(e) {
              alert(document.getElementById('scrollviewwrapper').scrollTop);
              var keyCode = e.keyCode;

              if(keyCode==38) {
              // up arrow

              } else if(keyCode==40) {
              // down arrow
              }
              }

              .overlay{
              position: absolute;
              height: 200px;
              width: 500px;
              top: 50px;
              left: 20px;
              bottom : 50px;
              z-index: 100;
              }

              .scrollviewwrapper{
              position: relative;
              background: red;
              height: 200px;
              width: 500px;
              padding-top: 30px;
              padding-left: 30px;
              padding-right: 30px;
              padding-bottom: 30px;
              overflow:auto;
              }

              <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
              <html>
              <body>
              <div class="overlay">
              <div class="scrollviewwrapper" id="scrollviewwrapper">
              test
              </div>
              </div>
              </body>
              </html>





              Hope this helps.






              share|improve this answer























                Your Answer






                StackExchange.ifUsing("editor", function () {
                StackExchange.using("externalEditor", function () {
                StackExchange.using("snippets", function () {
                StackExchange.snippets.init();
                });
                });
                }, "code-snippets");

                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "1"
                };
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function() {
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled) {
                StackExchange.using("snippets", function() {
                createEditor();
                });
                }
                else {
                createEditor();
                }
                });

                function createEditor() {
                StackExchange.prepareEditor({
                heartbeatType: 'answer',
                autoActivateHeartbeat: false,
                convertImagesToLinks: true,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: 10,
                bindNavPrevention: true,
                postfix: "",
                imageUploader: {
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                },
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });


                }
                });














                draft saved

                draft discarded


















                StackExchange.ready(
                function () {
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53410962%2fpadding-not-applied-correctly-to-div-element%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                0














                Swap your absolute positioning around so your scroll view wrapper is inside the background:






                document.addEventListener("keydown", keyDownTextField, false);
                this.title_element = jQuery('.scrollviewwrapper', this.$el);

                this.title_element.html('<ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> <ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> ');

                function keyDownTextField(e) {
                alert(document.getElementById('scrollviewwrapper').scrollTop);
                var keyCode = e.keyCode;

                if (keyCode == 38) {
                // up arrow

                } else if (keyCode == 40) {
                // down arrow
                }
                }

                .overlay {
                position: relative;
                background: red;
                height: 200px;
                width: 500px;
                top: 50px;
                left: 20px;
                bottom: 50px;
                z-index: 100;
                }

                .scrollviewwrapper {
                position: absolute;
                top: 0; /* use all 4 co-ordinates instead of width and height so it fills the container */
                left: 0;
                right: 0;
                bottom: 0;
                padding: 30px; /* this is shorthand and will apply padding to all 4 sides */
                overflow: auto;
                }

                <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
                <html>

                <body>
                <div class="overlay">
                <div class="scrollviewwrapper" id="scrollviewwrapper">
                test
                </div>
                </div>
                </body>

                </html>








                share|improve this answer






























                  0














                  Swap your absolute positioning around so your scroll view wrapper is inside the background:






                  document.addEventListener("keydown", keyDownTextField, false);
                  this.title_element = jQuery('.scrollviewwrapper', this.$el);

                  this.title_element.html('<ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> <ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> ');

                  function keyDownTextField(e) {
                  alert(document.getElementById('scrollviewwrapper').scrollTop);
                  var keyCode = e.keyCode;

                  if (keyCode == 38) {
                  // up arrow

                  } else if (keyCode == 40) {
                  // down arrow
                  }
                  }

                  .overlay {
                  position: relative;
                  background: red;
                  height: 200px;
                  width: 500px;
                  top: 50px;
                  left: 20px;
                  bottom: 50px;
                  z-index: 100;
                  }

                  .scrollviewwrapper {
                  position: absolute;
                  top: 0; /* use all 4 co-ordinates instead of width and height so it fills the container */
                  left: 0;
                  right: 0;
                  bottom: 0;
                  padding: 30px; /* this is shorthand and will apply padding to all 4 sides */
                  overflow: auto;
                  }

                  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
                  <html>

                  <body>
                  <div class="overlay">
                  <div class="scrollviewwrapper" id="scrollviewwrapper">
                  test
                  </div>
                  </div>
                  </body>

                  </html>








                  share|improve this answer




























                    0












                    0








                    0







                    Swap your absolute positioning around so your scroll view wrapper is inside the background:






                    document.addEventListener("keydown", keyDownTextField, false);
                    this.title_element = jQuery('.scrollviewwrapper', this.$el);

                    this.title_element.html('<ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> <ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> ');

                    function keyDownTextField(e) {
                    alert(document.getElementById('scrollviewwrapper').scrollTop);
                    var keyCode = e.keyCode;

                    if (keyCode == 38) {
                    // up arrow

                    } else if (keyCode == 40) {
                    // down arrow
                    }
                    }

                    .overlay {
                    position: relative;
                    background: red;
                    height: 200px;
                    width: 500px;
                    top: 50px;
                    left: 20px;
                    bottom: 50px;
                    z-index: 100;
                    }

                    .scrollviewwrapper {
                    position: absolute;
                    top: 0; /* use all 4 co-ordinates instead of width and height so it fills the container */
                    left: 0;
                    right: 0;
                    bottom: 0;
                    padding: 30px; /* this is shorthand and will apply padding to all 4 sides */
                    overflow: auto;
                    }

                    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
                    <html>

                    <body>
                    <div class="overlay">
                    <div class="scrollviewwrapper" id="scrollviewwrapper">
                    test
                    </div>
                    </div>
                    </body>

                    </html>








                    share|improve this answer















                    Swap your absolute positioning around so your scroll view wrapper is inside the background:






                    document.addEventListener("keydown", keyDownTextField, false);
                    this.title_element = jQuery('.scrollviewwrapper', this.$el);

                    this.title_element.html('<ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> <ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> ');

                    function keyDownTextField(e) {
                    alert(document.getElementById('scrollviewwrapper').scrollTop);
                    var keyCode = e.keyCode;

                    if (keyCode == 38) {
                    // up arrow

                    } else if (keyCode == 40) {
                    // down arrow
                    }
                    }

                    .overlay {
                    position: relative;
                    background: red;
                    height: 200px;
                    width: 500px;
                    top: 50px;
                    left: 20px;
                    bottom: 50px;
                    z-index: 100;
                    }

                    .scrollviewwrapper {
                    position: absolute;
                    top: 0; /* use all 4 co-ordinates instead of width and height so it fills the container */
                    left: 0;
                    right: 0;
                    bottom: 0;
                    padding: 30px; /* this is shorthand and will apply padding to all 4 sides */
                    overflow: auto;
                    }

                    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
                    <html>

                    <body>
                    <div class="overlay">
                    <div class="scrollviewwrapper" id="scrollviewwrapper">
                    test
                    </div>
                    </div>
                    </body>

                    </html>








                    document.addEventListener("keydown", keyDownTextField, false);
                    this.title_element = jQuery('.scrollviewwrapper', this.$el);

                    this.title_element.html('<ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> <ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> ');

                    function keyDownTextField(e) {
                    alert(document.getElementById('scrollviewwrapper').scrollTop);
                    var keyCode = e.keyCode;

                    if (keyCode == 38) {
                    // up arrow

                    } else if (keyCode == 40) {
                    // down arrow
                    }
                    }

                    .overlay {
                    position: relative;
                    background: red;
                    height: 200px;
                    width: 500px;
                    top: 50px;
                    left: 20px;
                    bottom: 50px;
                    z-index: 100;
                    }

                    .scrollviewwrapper {
                    position: absolute;
                    top: 0; /* use all 4 co-ordinates instead of width and height so it fills the container */
                    left: 0;
                    right: 0;
                    bottom: 0;
                    padding: 30px; /* this is shorthand and will apply padding to all 4 sides */
                    overflow: auto;
                    }

                    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
                    <html>

                    <body>
                    <div class="overlay">
                    <div class="scrollviewwrapper" id="scrollviewwrapper">
                    test
                    </div>
                    </div>
                    </body>

                    </html>





                    document.addEventListener("keydown", keyDownTextField, false);
                    this.title_element = jQuery('.scrollviewwrapper', this.$el);

                    this.title_element.html('<ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> <ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> ');

                    function keyDownTextField(e) {
                    alert(document.getElementById('scrollviewwrapper').scrollTop);
                    var keyCode = e.keyCode;

                    if (keyCode == 38) {
                    // up arrow

                    } else if (keyCode == 40) {
                    // down arrow
                    }
                    }

                    .overlay {
                    position: relative;
                    background: red;
                    height: 200px;
                    width: 500px;
                    top: 50px;
                    left: 20px;
                    bottom: 50px;
                    z-index: 100;
                    }

                    .scrollviewwrapper {
                    position: absolute;
                    top: 0; /* use all 4 co-ordinates instead of width and height so it fills the container */
                    left: 0;
                    right: 0;
                    bottom: 0;
                    padding: 30px; /* this is shorthand and will apply padding to all 4 sides */
                    overflow: auto;
                    }

                    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
                    <html>

                    <body>
                    <div class="overlay">
                    <div class="scrollviewwrapper" id="scrollviewwrapper">
                    test
                    </div>
                    </div>
                    </body>

                    </html>






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Nov 21 '18 at 11:32

























                    answered Nov 21 '18 at 11:24









                    PetePete

                    41.7k1877120




                    41.7k1877120

























                        1














                        Add box-sizing:border-box; rule to your .scrollviewwrapper class:






                        document.addEventListener("keydown", keyDownTextField, false);
                        this.title_element = jQuery('.scrollviewwrapper', this.$el);

                        this.title_element.html('<ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> <ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> ');

                        function keyDownTextField(e) {
                        alert(document.getElementById('scrollviewwrapper').scrollTop);
                        var keyCode = e.keyCode;

                        if(keyCode==38) {
                        // up arrow

                        } else if(keyCode==40) {
                        // down arrow
                        }
                        }

                        .overlay{
                        position: absolute;
                        background: red;
                        height: 200px;
                        width: 500px;
                        top: 50px;
                        left: 20px;
                        bottom : 50px;
                        z-index: 100;
                        }

                        .scrollviewwrapper{
                        position: relative;
                        height: 200px;
                        width: 500px;
                        padding-top: 30px;
                        padding-left: 30px;
                        padding-right: 30px;
                        padding-bottom: 30px;
                        overflow:auto;
                        box-sizing:border-box;
                        }

                        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
                        <html>
                        <body>
                        <div class="overlay">
                        <div class="scrollviewwrapper" id="scrollviewwrapper">
                        test
                        </div>
                        </div>
                        </body>
                        </html>








                        share|improve this answer




























                          1














                          Add box-sizing:border-box; rule to your .scrollviewwrapper class:






                          document.addEventListener("keydown", keyDownTextField, false);
                          this.title_element = jQuery('.scrollviewwrapper', this.$el);

                          this.title_element.html('<ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> <ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> ');

                          function keyDownTextField(e) {
                          alert(document.getElementById('scrollviewwrapper').scrollTop);
                          var keyCode = e.keyCode;

                          if(keyCode==38) {
                          // up arrow

                          } else if(keyCode==40) {
                          // down arrow
                          }
                          }

                          .overlay{
                          position: absolute;
                          background: red;
                          height: 200px;
                          width: 500px;
                          top: 50px;
                          left: 20px;
                          bottom : 50px;
                          z-index: 100;
                          }

                          .scrollviewwrapper{
                          position: relative;
                          height: 200px;
                          width: 500px;
                          padding-top: 30px;
                          padding-left: 30px;
                          padding-right: 30px;
                          padding-bottom: 30px;
                          overflow:auto;
                          box-sizing:border-box;
                          }

                          <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
                          <html>
                          <body>
                          <div class="overlay">
                          <div class="scrollviewwrapper" id="scrollviewwrapper">
                          test
                          </div>
                          </div>
                          </body>
                          </html>








                          share|improve this answer


























                            1












                            1








                            1







                            Add box-sizing:border-box; rule to your .scrollviewwrapper class:






                            document.addEventListener("keydown", keyDownTextField, false);
                            this.title_element = jQuery('.scrollviewwrapper', this.$el);

                            this.title_element.html('<ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> <ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> ');

                            function keyDownTextField(e) {
                            alert(document.getElementById('scrollviewwrapper').scrollTop);
                            var keyCode = e.keyCode;

                            if(keyCode==38) {
                            // up arrow

                            } else if(keyCode==40) {
                            // down arrow
                            }
                            }

                            .overlay{
                            position: absolute;
                            background: red;
                            height: 200px;
                            width: 500px;
                            top: 50px;
                            left: 20px;
                            bottom : 50px;
                            z-index: 100;
                            }

                            .scrollviewwrapper{
                            position: relative;
                            height: 200px;
                            width: 500px;
                            padding-top: 30px;
                            padding-left: 30px;
                            padding-right: 30px;
                            padding-bottom: 30px;
                            overflow:auto;
                            box-sizing:border-box;
                            }

                            <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
                            <html>
                            <body>
                            <div class="overlay">
                            <div class="scrollviewwrapper" id="scrollviewwrapper">
                            test
                            </div>
                            </div>
                            </body>
                            </html>








                            share|improve this answer













                            Add box-sizing:border-box; rule to your .scrollviewwrapper class:






                            document.addEventListener("keydown", keyDownTextField, false);
                            this.title_element = jQuery('.scrollviewwrapper', this.$el);

                            this.title_element.html('<ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> <ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> ');

                            function keyDownTextField(e) {
                            alert(document.getElementById('scrollviewwrapper').scrollTop);
                            var keyCode = e.keyCode;

                            if(keyCode==38) {
                            // up arrow

                            } else if(keyCode==40) {
                            // down arrow
                            }
                            }

                            .overlay{
                            position: absolute;
                            background: red;
                            height: 200px;
                            width: 500px;
                            top: 50px;
                            left: 20px;
                            bottom : 50px;
                            z-index: 100;
                            }

                            .scrollviewwrapper{
                            position: relative;
                            height: 200px;
                            width: 500px;
                            padding-top: 30px;
                            padding-left: 30px;
                            padding-right: 30px;
                            padding-bottom: 30px;
                            overflow:auto;
                            box-sizing:border-box;
                            }

                            <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
                            <html>
                            <body>
                            <div class="overlay">
                            <div class="scrollviewwrapper" id="scrollviewwrapper">
                            test
                            </div>
                            </div>
                            </body>
                            </html>








                            document.addEventListener("keydown", keyDownTextField, false);
                            this.title_element = jQuery('.scrollviewwrapper', this.$el);

                            this.title_element.html('<ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> <ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> ');

                            function keyDownTextField(e) {
                            alert(document.getElementById('scrollviewwrapper').scrollTop);
                            var keyCode = e.keyCode;

                            if(keyCode==38) {
                            // up arrow

                            } else if(keyCode==40) {
                            // down arrow
                            }
                            }

                            .overlay{
                            position: absolute;
                            background: red;
                            height: 200px;
                            width: 500px;
                            top: 50px;
                            left: 20px;
                            bottom : 50px;
                            z-index: 100;
                            }

                            .scrollviewwrapper{
                            position: relative;
                            height: 200px;
                            width: 500px;
                            padding-top: 30px;
                            padding-left: 30px;
                            padding-right: 30px;
                            padding-bottom: 30px;
                            overflow:auto;
                            box-sizing:border-box;
                            }

                            <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
                            <html>
                            <body>
                            <div class="overlay">
                            <div class="scrollviewwrapper" id="scrollviewwrapper">
                            test
                            </div>
                            </div>
                            </body>
                            </html>





                            document.addEventListener("keydown", keyDownTextField, false);
                            this.title_element = jQuery('.scrollviewwrapper', this.$el);

                            this.title_element.html('<ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> <ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> ');

                            function keyDownTextField(e) {
                            alert(document.getElementById('scrollviewwrapper').scrollTop);
                            var keyCode = e.keyCode;

                            if(keyCode==38) {
                            // up arrow

                            } else if(keyCode==40) {
                            // down arrow
                            }
                            }

                            .overlay{
                            position: absolute;
                            background: red;
                            height: 200px;
                            width: 500px;
                            top: 50px;
                            left: 20px;
                            bottom : 50px;
                            z-index: 100;
                            }

                            .scrollviewwrapper{
                            position: relative;
                            height: 200px;
                            width: 500px;
                            padding-top: 30px;
                            padding-left: 30px;
                            padding-right: 30px;
                            padding-bottom: 30px;
                            overflow:auto;
                            box-sizing:border-box;
                            }

                            <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
                            <html>
                            <body>
                            <div class="overlay">
                            <div class="scrollviewwrapper" id="scrollviewwrapper">
                            test
                            </div>
                            </div>
                            </body>
                            </html>






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Nov 21 '18 at 11:20









                            aMJayaMJay

                            1,55621222




                            1,55621222























                                0














                                you need to add the background: red; to your .scrollviewwrapper class:






                                document.addEventListener("keydown", keyDownTextField, false);
                                this.title_element = jQuery('.scrollviewwrapper', this.$el);

                                this.title_element.html('<ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> <ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> ');

                                function keyDownTextField(e) {
                                alert(document.getElementById('scrollviewwrapper').scrollTop);
                                var keyCode = e.keyCode;

                                if(keyCode==38) {
                                // up arrow

                                } else if(keyCode==40) {
                                // down arrow
                                }
                                }

                                .overlay{
                                position: absolute;
                                height: 200px;
                                width: 500px;
                                top: 50px;
                                left: 20px;
                                bottom : 50px;
                                z-index: 100;
                                }

                                .scrollviewwrapper{
                                position: relative;
                                background: red;
                                height: 200px;
                                width: 500px;
                                padding-top: 30px;
                                padding-left: 30px;
                                padding-right: 30px;
                                padding-bottom: 30px;
                                overflow:auto;
                                }

                                <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
                                <html>
                                <body>
                                <div class="overlay">
                                <div class="scrollviewwrapper" id="scrollviewwrapper">
                                test
                                </div>
                                </div>
                                </body>
                                </html>





                                Hope this helps.






                                share|improve this answer




























                                  0














                                  you need to add the background: red; to your .scrollviewwrapper class:






                                  document.addEventListener("keydown", keyDownTextField, false);
                                  this.title_element = jQuery('.scrollviewwrapper', this.$el);

                                  this.title_element.html('<ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> <ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> ');

                                  function keyDownTextField(e) {
                                  alert(document.getElementById('scrollviewwrapper').scrollTop);
                                  var keyCode = e.keyCode;

                                  if(keyCode==38) {
                                  // up arrow

                                  } else if(keyCode==40) {
                                  // down arrow
                                  }
                                  }

                                  .overlay{
                                  position: absolute;
                                  height: 200px;
                                  width: 500px;
                                  top: 50px;
                                  left: 20px;
                                  bottom : 50px;
                                  z-index: 100;
                                  }

                                  .scrollviewwrapper{
                                  position: relative;
                                  background: red;
                                  height: 200px;
                                  width: 500px;
                                  padding-top: 30px;
                                  padding-left: 30px;
                                  padding-right: 30px;
                                  padding-bottom: 30px;
                                  overflow:auto;
                                  }

                                  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
                                  <html>
                                  <body>
                                  <div class="overlay">
                                  <div class="scrollviewwrapper" id="scrollviewwrapper">
                                  test
                                  </div>
                                  </div>
                                  </body>
                                  </html>





                                  Hope this helps.






                                  share|improve this answer


























                                    0












                                    0








                                    0







                                    you need to add the background: red; to your .scrollviewwrapper class:






                                    document.addEventListener("keydown", keyDownTextField, false);
                                    this.title_element = jQuery('.scrollviewwrapper', this.$el);

                                    this.title_element.html('<ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> <ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> ');

                                    function keyDownTextField(e) {
                                    alert(document.getElementById('scrollviewwrapper').scrollTop);
                                    var keyCode = e.keyCode;

                                    if(keyCode==38) {
                                    // up arrow

                                    } else if(keyCode==40) {
                                    // down arrow
                                    }
                                    }

                                    .overlay{
                                    position: absolute;
                                    height: 200px;
                                    width: 500px;
                                    top: 50px;
                                    left: 20px;
                                    bottom : 50px;
                                    z-index: 100;
                                    }

                                    .scrollviewwrapper{
                                    position: relative;
                                    background: red;
                                    height: 200px;
                                    width: 500px;
                                    padding-top: 30px;
                                    padding-left: 30px;
                                    padding-right: 30px;
                                    padding-bottom: 30px;
                                    overflow:auto;
                                    }

                                    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
                                    <html>
                                    <body>
                                    <div class="overlay">
                                    <div class="scrollviewwrapper" id="scrollviewwrapper">
                                    test
                                    </div>
                                    </div>
                                    </body>
                                    </html>





                                    Hope this helps.






                                    share|improve this answer













                                    you need to add the background: red; to your .scrollviewwrapper class:






                                    document.addEventListener("keydown", keyDownTextField, false);
                                    this.title_element = jQuery('.scrollviewwrapper', this.$el);

                                    this.title_element.html('<ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> <ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> ');

                                    function keyDownTextField(e) {
                                    alert(document.getElementById('scrollviewwrapper').scrollTop);
                                    var keyCode = e.keyCode;

                                    if(keyCode==38) {
                                    // up arrow

                                    } else if(keyCode==40) {
                                    // down arrow
                                    }
                                    }

                                    .overlay{
                                    position: absolute;
                                    height: 200px;
                                    width: 500px;
                                    top: 50px;
                                    left: 20px;
                                    bottom : 50px;
                                    z-index: 100;
                                    }

                                    .scrollviewwrapper{
                                    position: relative;
                                    background: red;
                                    height: 200px;
                                    width: 500px;
                                    padding-top: 30px;
                                    padding-left: 30px;
                                    padding-right: 30px;
                                    padding-bottom: 30px;
                                    overflow:auto;
                                    }

                                    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
                                    <html>
                                    <body>
                                    <div class="overlay">
                                    <div class="scrollviewwrapper" id="scrollviewwrapper">
                                    test
                                    </div>
                                    </div>
                                    </body>
                                    </html>





                                    Hope this helps.






                                    document.addEventListener("keydown", keyDownTextField, false);
                                    this.title_element = jQuery('.scrollviewwrapper', this.$el);

                                    this.title_element.html('<ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> <ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> ');

                                    function keyDownTextField(e) {
                                    alert(document.getElementById('scrollviewwrapper').scrollTop);
                                    var keyCode = e.keyCode;

                                    if(keyCode==38) {
                                    // up arrow

                                    } else if(keyCode==40) {
                                    // down arrow
                                    }
                                    }

                                    .overlay{
                                    position: absolute;
                                    height: 200px;
                                    width: 500px;
                                    top: 50px;
                                    left: 20px;
                                    bottom : 50px;
                                    z-index: 100;
                                    }

                                    .scrollviewwrapper{
                                    position: relative;
                                    background: red;
                                    height: 200px;
                                    width: 500px;
                                    padding-top: 30px;
                                    padding-left: 30px;
                                    padding-right: 30px;
                                    padding-bottom: 30px;
                                    overflow:auto;
                                    }

                                    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
                                    <html>
                                    <body>
                                    <div class="overlay">
                                    <div class="scrollviewwrapper" id="scrollviewwrapper">
                                    test
                                    </div>
                                    </div>
                                    </body>
                                    </html>





                                    document.addEventListener("keydown", keyDownTextField, false);
                                    this.title_element = jQuery('.scrollviewwrapper', this.$el);

                                    this.title_element.html('<ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> <ul>r<li>Fermentum congue dictumst integer sapien conubia, per volutpat a duis donec, habitasse quisque tristique hac</li>r<li>Imperdiet aliquam praesent id viverra aliquam inceptos</li>r<li>Cubilia litora placerat fusce vulputate habitant varius cursus molestie lorem magna mi non</li>r<li>Imperdiet sociosqu aenean ornare sagittis faucibus in facilisis vitae, lobortis curae hac justo tellus tincidunt</li>r<li>Urna eu consequat non consectetur duis ut justo eleifend sapien</li>r</ul> ');

                                    function keyDownTextField(e) {
                                    alert(document.getElementById('scrollviewwrapper').scrollTop);
                                    var keyCode = e.keyCode;

                                    if(keyCode==38) {
                                    // up arrow

                                    } else if(keyCode==40) {
                                    // down arrow
                                    }
                                    }

                                    .overlay{
                                    position: absolute;
                                    height: 200px;
                                    width: 500px;
                                    top: 50px;
                                    left: 20px;
                                    bottom : 50px;
                                    z-index: 100;
                                    }

                                    .scrollviewwrapper{
                                    position: relative;
                                    background: red;
                                    height: 200px;
                                    width: 500px;
                                    padding-top: 30px;
                                    padding-left: 30px;
                                    padding-right: 30px;
                                    padding-bottom: 30px;
                                    overflow:auto;
                                    }

                                    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
                                    <html>
                                    <body>
                                    <div class="overlay">
                                    <div class="scrollviewwrapper" id="scrollviewwrapper">
                                    test
                                    </div>
                                    </div>
                                    </body>
                                    </html>






                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Nov 21 '18 at 11:21









                                    Serge InácioSerge Inácio

                                    1,126817




                                    1,126817






























                                        draft saved

                                        draft discarded




















































                                        Thanks for contributing an answer to Stack Overflow!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid



                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.


                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function () {
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53410962%2fpadding-not-applied-correctly-to-div-element%23new-answer', 'question_page');
                                        }
                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown







                                        Popular posts from this blog

                                        mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

                                        How to change which sound is reproduced for terminal bell?

                                        Can I use Tabulator js library in my java Spring + Thymeleaf project?