html - 我把同样大小的图片和视频分别放到一个父div中,但是它们的父div大小不一样?

标签 html css twitter-bootstrap

我将相同大小的图像 (300x400) 和视频 (300x400) 分别放入父 div。

<div class="bgimage col-md-12 col-sm-12 col-xs-12 ">
            <div class="ol-md-6 col-sm-6 col-xs-12">
              <img  src="img"  >
            </div>
</div>

 <div class="bgimage col-md-12 col-sm-12 col-xs-12 ">
        <div class="ol-md-6 col-sm-6 col-xs-12">
               <video   loop autoplay class="autov">
                  <source src="./resources/img/Video.mp4" type="video/mp4">
                </video> 
        </div>
    </div>

这是css中的定义。

.bgimage {
   background-image: url(../img/bg2.png);

    /* Full height */
    height: 100%; 
    width:100%;
    padding: 30px 50px 30px 50px;
    /* Background image is centered vertically and horizontally at all times */
    background-position: center center;

    /* Background image doesn't tile */
     background-repeat: no-repeat;
    /* This is what makes the background image rescale based
     on the container's size */
    background-size: 100% 100%;

    /* Set a background color that will be displayed
     while the background image is loading */
    background-color: #red;
}

但是视频的容器高度稍大。

最佳答案

虽然到目前为止,我从未在 video 元素中遇到过这种情况,但在使用内联图像时,修复方法是一样的,而且非常简单: 将 vertical-align: top; 作为样式添加到您的视频元素,额外的空白将消失。

关于html - 我把同样大小的图片和视频分别放到一个父div中,但是它们的父div大小不一样?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47100050/

相关文章:

css - Bootstrap 使 iPhone 的缩放比例与 iPad 相同。

html - 如何用 Twitter Bootstrap 导航栏上的图像替换品牌文本?

html - 如何对齐 bootstrap div 中的内容,使其触及父 div 的边距

javascript - Twitter Bootstrap javascript 弹出窗口不起作用

javascript - Babylon.js OnIntersectionEnterTrigger 未使用相机触发

php - strip_tags : strip off the messy tags and styles

html - 如何使用箭头使图像填充 div?

javascript - 属性大于传递变量 (.filter()) 的 jQuery 元素

html - 使垂直菜单中的所有 <li> 具有相同的宽度 CSS

jquery - 加载窗口时 SVG 绘制动画进度