How to inherit Image width and height to video tag


Tags: html,css

Problem :

Image has width 400x400 as per real image property. Now I have sibling video which should have the same width and height of the image. How can I inherit Image width and height property to video tag

HTML:

<div id="holder">
<img src="http://placehold.it/400x400" >
<video controls="">
  <source src="mov_bbb.mp4" type="video/mp4">
  Your browser does not support HTML5 video.
</video>
</div>

CSS:

#holder {
  position: relative;
}

#stuff {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

http://codepen.io/snehav27/pen/mJoyPO



Solution :

turn stuff into a class and then put div class="stuff" around the video

#holder {
  position: absolute;
 height:400px;
 width:auto;
}

.stuff {
  position: absolute;
  height:inherit;
  width:inherit;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

.stuff video{position:absolute;
            height:inherit;
            width:inherit;
            vertical-align:top;}

    CSS Howto..

    How to display “Classic” fractions in CSS / Javascript

    How to use Javascript to close css drop down menu on outside click?

    How to check “IF any one or all buttons are clicked” in jquery

    How to float div in CSS?

    How to set a fixed background with CSS?

    How to convert columns to rows using CSS

    How can I force CQ5.5 to ignore CSS data-uri-schemes?

    how do I find out which skin Telerik's RADeditor is using by default?

    how to scroll text area horizontally?

    My sidebar is fixed no matter what. How do I make scrolling possible with the sidebar?

    How can I reduce the spacing between my legend and chart proper in my Chart.JS bar chart, and increase it in the graph area?

    how do i fit background image to any screen?

    How do I simulate a hover with a touch in touch enabled browsers?

    How to change a Pseudo-class style through JavaScript?

    How to Center a image with HTML CSS

    How do I add a class to a default bootstrap class

    How can I use jQuery to create a csv of all checked checkboxes associated text?

    How can I fix this 3-column layout?

    How to Mask Images with Dynamic Sizes to Shapes?

    CSS how to vertically align text within a pseudo element

    How to work with boxes? Html Css

    How to detect browser support for :after and :before

    How to show one element when click on the another element with css?

    How to create angled double border effect CSS

    How do I style a different border?

    How to make footer responsive through CSS?

    How to add custom layout and css in a CakePHP application?

    How to prevent adding CSS 'class' properties

    How to prevent CSS inheritance where child selectors fail?

    How Do I Make My CSS Slider Auto Play? [closed]