css - div 高度不能100% ,急

查看:147
本文介绍了css - div 高度不能100% ,急的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="http://www.jq22.com/demo/video-js/css/video-js.css">
    <script src="http://vjs.zencdn.net/5.18.4/video.min.js"></script>    
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        body,
        html {
            overflow: hidden;
            height: 100%;
        }
        #app {
            width: 100%;
            height: 100%;
            display: -webkit-flex;
        }
        #app .a {
            -webkit-flex: 5.5;
            overflow: hidden;
        }
        .a video {
            height: 100%;
        }
        #app .b {
            -webkit-flex: 4.5;
        }
        .a > div {
            width: 100%;
            height: 100% !important;
        }
    </style>
</head>
<body>
<div id="app">
    <div class="a">
        
    </div>
    <div class="b"></div>
</div>
<script>
setTimeout(function(){
    var a = document.querySelectorAll('.a')[0];
    var x = 'http://vjs.zencdn.net/v/oceans.mp4';
    a.innerHTML = `<video src="${x}" id="xx" autoplay="autoplay" loop="loop"></video>`;
    videojs("xx").ready(function(){
        this.play();
    });
},1000);
</script>
</body>
</html>

代码直接复制过去就能看效果了。

.a 类名下面的div 高度明明设置了100%,

chrome 没问题可以100%; 其他webkit内核的浏览器不能100%, 测试的是360安全浏览器,和搜狗浏览器都有这个问题。

解决方案

当你设置一个页面元素的高度(height)为100%时,期望这样元素能撑满整个浏览器窗口的高度,但大多数情况下,这样的做法没有任何效果。你知道为什么height:100%不起作用吗?
http://www.webhek.com/css-100...

这篇关于css - div 高度不能100% ,急的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆