Html 如何将图像宽度和高度继承到视频标签

Html 如何将图像宽度和高度继承到视频标签,html,css,Html,Css,根据real Image属性,图像宽度为400x400。 现在我有兄弟视频,应该有相同的宽度和高度的图像。 如何将图像宽度和高度属性继承到视频标记 HTML: 将stuff转换为一个类,然后在视频中添加div class=“stuff” #holder { position: absolute; height:400px; width:auto; } .stuff { position: absolute; height:inherit; width:inherit;

根据real Image属性,图像宽度为400x400。 现在我有兄弟视频,应该有相同的宽度和高度的图像。 如何将图像宽度和高度属性继承到视频标记

HTML:


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

如果您的图像始终为400x400,只需将
height=“400”width=“400”
添加到视频标记。您尝试过使用JavaScript吗?首先,标记必须自动关闭,如
第二,如果您知道尺寸,您不能仅在css中静态设置它们吗?兄弟不能相互继承。继承仅在父/子情况下有效。但是您可以设置div容器的大小,并让两者从中继承。@oxguy3我不想手动添加,因为我会为不同的图像设置不同的宽度和高度,我只希望它动态继承高度和宽度的属性。您可以检查代码笔吗,解决方案不起作用。您必须为支架设置高度,但可以将宽度设置为“自动”,也可以将两者都设置为“自动”,以获取帮助:)接受答案
#holder {
  position: relative;
}

#stuff {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}
#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;}