title: HTML CSS video inside flexbox
body: <pre><code>&lt;!DOCTYPE html&gt; 
  &lt;html&gt;
  &lt;style&gt;
  .d1 {
      background: blue;
      padding: 10px;
      display: flex;
  }
  video {
      margin: 10px;
      width: 100%;
      max-width: 500px;
  }
  &lt;/style&gt;
  &lt;body&gt; 
  
  &lt;div class="d1"&gt;
    &lt;video controls&gt;
      &lt;source src="mov_bbb.mp4" type="video/mp4"&gt;
      &lt;source src="mov_bbb.ogg" type="video/ogg"&gt;
      Your browser does not support HTML5 video.
    &lt;/video&gt;
  &lt;/div&gt;
  
  &lt;/body&gt; 
  &lt;/html&gt;
  </code></pre>
  
  <p>I use a <code>video</code> inside a <code>flexbox</code> like the above and the code works fine except two points: <strong>1)</strong> The video size does not fit the control line that is below. How can I make it fit? I think it has something to do with the alignment... <strong>2)</strong> I want the <code>video</code> to be resized horizontally only. For that, I searched and use <code>width: 100%</code> and it works but as I resize it the right part seems to ignore the <code>margin</code> that I give it:</p>
  
  <p><a href="https://i.stack.imgur.com/Gm1My.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Gm1My.png" alt="enter image description here"></a></p>