title: Image not resizing to parent or grandparents using %
body: <p>i am making a modal from ww3 school website. I have a button that opens the modal and i tried to add an image inside the modal but i cant make the image resize based off any of its parent/grandparent divs. </p>
  
  <p>i tried max width, width.. no success</p>
  
  <p>it wont resize in % only in pixels, as i understand % only works if containing div has a defined height which is does so what gives??</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>// Get the modal
  var modal = document.getElementById('myModal');
  
  // Get the button that opens the modal
  var btn = document.getElementById("myBtn");
  
  // Get the &lt;span&gt; element that closes the modal
  var span = document.getElementsByClassName("close")[0];
  
  // When the user clicks on the button, open the modal 
  btn.onclick = function() {
    modal.style.display = "block";
  }
  
  // When the user clicks on &lt;span&gt; (x), close the modal
  span.onclick = function() {
    modal.style.display = "none";
  }
  
  // When the user clicks anywhere outside of the modal, close it
  window.onclick = function(event) {
    if (event.target == modal) {
      modal.style.display = "none";
    }
  }</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>/* The Modal (background) */
  .modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgb(0,0,0); /* Fallback color */
    background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
  }
  
  /* Modal Content/Box */
  .modal-content {
    background-color: #fefefe;
    margin: 15% auto; /* 15% from the top and centered */
    padding: 20px;
    border: 1px solid #888;
    width: 60%; /* Could be more or less, depending on screen size */
    height: 50px;
  }
  
  /* The Close Button */
  .close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
  }
  
  .close:hover,
  .close:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
  }
  
  /// END OF MODAL CSS /// END OF MODAL CSS/// END OF MODAL CSS/// END OF MODAL CSS/// END OF MODAL CSS/// END OF MODAL CSS/// END OF MODAL CSS/// END OF MODAL CSS/// END OF MODAL CSS
  
  .image_holder{
  height: 100px;
  width: 100px;
  }
  
  
  .modal__img{
    max-height: 50%;
    max-width: 50%;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;body&gt;
  
  &lt;button id="myBtn"&gt;Book&lt;/button&gt;
  
  &lt;!-- The Modal --&gt;
    &lt;div id="myModal" class="modal"&gt;
  
    &lt;!-- Modal content --&gt;
     &lt;div class="modal-content"&gt;
        &lt;span class="close"&gt;&amp;times;&lt;/span&gt;
        &lt;div class="image_holder"&gt;
              &lt;img class="modal__img" src="https://via.placeholder.com/300.png/09f/fff"&gt; 
          &lt;/div&gt;
        &lt;p&gt;accomodationaccomodationaccomodationaccomodationaccomodationaccomodationaccomodation &lt;/p&gt;
  
    &lt;/div&gt;
  
  &lt;/div&gt;
  &lt;!-- Modal content --&gt;
  
  
  
  
  &lt;/body&gt;
  
  &lt;script type="text/javascript" src="js/script.js"&gt;&lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>