0

In the code below, why 'overflow-y' is not working in class 'dialogo'? I tried somehow and I could not. Responsive CSS seems confusing many times.

    <meta name="viewport" content="width=device-width, initial-scale=1">
<style>
html,body,div,menu,
video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    overflow-x: hidden;
}
</style>
<style>
html {
  background: #E2CE99;
}
.container {
  position: relative;
  width: 70%;
  background-color: red;

  font-family: helvetica, sans-serif;
  border: 2px solid black;
  float: left;
  left: 2%;

  padding-left: 2px;
}
.containerd {
  position: relative;
  width: 70%;
  background-color: white;

  font-family: helvetica, sans-serif;
  border: 2px solid black;
  float: right;
  right: 2%;

  padding-left: 2px;
}
.content {
  position: relative;
  padding-top: 10px;
}
.content p {

}
#header {
  z-index: 2;
  position: fixed;
  width: 100%;
  height: 60px;
  line-height: 60px;
  background: #CC1111;
  color: white;
}
#header h1 {
  position: absolute;
  top: 0;
  left: 0;
  text-transform: uppercase;
}
    .dialogo{
        resize: vertical;
        width: 100%;
        top: 1%;
        position: relative;
        font-size: 15px;
        overflow-y: scroll;
        background-color: white;
        word-wrap:break-word;
        text-align: left;
        border:1px solid black;
        height: 50%;
    }

    </style>
</head>
<header id="header">
    <center>Jhon</center>
</header>
<div style="padding-top: 70px;"></div>
<div class = dialogo disabled id="texConv" name="texConv">
<div class="content">
  <div class="container">
  <p>HELLO</p>
  </div>
</div>
<div class="content">
  <div class="containerd">
  <p>HELLO</p>
  </div>
</div>
</div>
<br>
<div class="content">&nbsp 2017</div>
</html>

So I would like to know how to put a height in percentages for a div containing as boxes and turn on the scroll-Y.

1 Answers1

0

For overflow-y to work, the height of the content in the element needs to exceed the specified height. I changed the height to 5em and you can see it's working.

<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
  html,
  body,
  div,
  menu,
  video {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    overflow-x: hidden;
  }
</style>
<style>
  html {
    background: #E2CE99;
  }
  
  .container {
    position: relative;
    width: 70%;
    background-color: red;
    font-family: helvetica, sans-serif;
    border: 2px solid black;
    float: left;
    left: 2%;
    padding-left: 2px;
  }
  
  .containerd {
    position: relative;
    width: 70%;
    background-color: white;
    font-family: helvetica, sans-serif;
    border: 2px solid black;
    float: right;
    right: 2%;
    padding-left: 2px;
  }
  
  .content {
    position: relative;
    padding-top: 10px;
  }
  
  .content p {}
  
  #header {
    z-index: 2;
    position: fixed;
    width: 100%;
    height: 60px;
    line-height: 60px;
    background: #CC1111;
    color: white;
  }
  
  #header h1 {
    position: absolute;
    top: 0;
    left: 0;
    text-transform: uppercase;
  }
  
  .dialogo {
    resize: vertical;
    width: 100%;
    top: 1%;
    position: relative;
    font-size: 15px;
    overflow-y: scroll;
    background-color: white;
    word-wrap: break-word;
    text-align: left;
    border: 1px solid black;
    height: 5em;
  }
</style>
</head>
<header id="header">
  <center>Jhon</center>
</header>
<div style="padding-top: 70px;"></div>
<div class="dialogo" disabled id="texConv" name="texConv">
  <div class="content">
    <div class="container">
      <p>HELLO</p>
    </div>
  </div>
  <div class="content">
    <div class="containerd">
      <p>HELLO</p>
    </div>
  </div>
</div>
<br>
<div class="content">&nbsp 2017</div>

</html>
Michael Coker
  • 52,626
  • 5
  • 64
  • 64