如何继承图像的宽度和高度视频标签



图像宽度为400x400,根据实际图像属性。现在我有了一个兄弟视频它的宽度和高度应该与图像相同。如何将图像宽度和高度属性继承到视频标签

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

把stuff变成一个类,然后在视频周围加上div class="stuff"

#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;}

最新更新