HTML Element Style How to - Make double sized div with scrolling








Question

We would like to know how to make double sized div with scrolling.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#div1 {<!-- w  w  w  .  j  a  va2s.  c  o  m-->
  width: 98%;
  background-color: #eee;
  overflow-x: scroll;
}

#div2 {
  border-left: 2px dashed #4e4e4e;
  border-right: 2px dashed #4e4e4e;
  width: 200%;
  height: 100px;
  background-color: #ddd;
}
</style>
</head>
<body>
    <div id='div1'>
      <div id='div2'></div>
    </div>
</body>
</html>

The code above is rendered as follows: