当用户启动应用程序时,我需要全屏显示视频,当用户按“M”时,视频分区大小应该减小,并且需要在视频下显示一个分区,在分区内显示文本。文本应该在分区内水平和垂直对齐。我使用了display:table cell,但是T不起作用。下面是代码。
  
  
   
    HTML:
   
  
  <!DOCTYPE html>
    <html>
        <head>
            <title>VOD</title>
            <script src='js/index.js'></script>
            <style>
                html, body
                {
                    height:100%;
                    width: 100%;
                    overflow: hidden;
                    background-color: #2F4F4F;
                }
                #header {
                    position: fixed;
                    left: 0px;
                    top: 0px;
                    width: 100%;
                    height: 75px;
                    background-color: black;
                    color: white;
                    padding-left: 75px;
                    font-family: sans-serif;
                }
                #hdiv {
                    position: fixed;
                    left: 75px;
                    top: 300px;
                    height: 100%;
                    width: 376px;
                    display: table;
                    box-shadow: inset 7px 0 9px -7px rgba(0,0,0,0.7), inset -7px 0 9px -7px rgba(0,0,0,0.7);
                }
                #htxtdiv {
                    width: 100%;
                    height: 50px;
                    color: white;
                    font-family: sans-serif;
                    display: table-cell;
                    vertical-align: middle;
                    text-align: center;
                }
                #vid.full {
                    position: fixed;
                    top: 50%;
                    left: 50%;
                    z-index: 3;
                    min-width: 100%;
                    min-height: 100%;
                    width: auto;
                    height: auto;
                    transform: translate(-50%, -50%);
                }
                #vid.pip {
                    position: fixed;
                    left: 75px;
                    top: 75px;
                    width: 376px;
                    height: 205px;
                    background-color:black;
                    border-left: 1px solid #b5b5b5;
                    border-right: 1px solid #b5b5b5;
                    border-bottom: 1px solid #b5b5b5;
                    z-index: 3;
                }
            </style>
        </head>
        <body>
            <div id='maindiv' style='display:none'>
                <div id='header'>
                    <h2>DVR</h2>
                </div>
                <div id='hdiv'>
                    <div id='htxtdiv'>
                        <h3>Cloud DVR Recordings</h3>
                    </div>
                </div>
            </div>
            <video id='vid' src='textMotion.mp4'class='full' autoplay></video>
        </body>
    </html>
  
   
    javascript代码:
   
  
  function displayMenu() {
    // If already menu is visible, hide it
    let vid = document.getElementById('vid');
    let mdiv = document.getElementById('maindiv');
    if(vid.classList.contains('pip') == true) {
        mdiv.style.display = 'none';
        vid.classList.add('full');
        vid.classList.remove('pip');
        return;
    }
    mdiv.style.display = 'block';
    vid.classList.add('pip');
    vid.classList.remove('full');
}
function processKeyPress(e) {
    console.log('received keyEvent : ' + e.keyCode);
    let keyCode = e.keyCode;
    // Menu button or key 'm'
    if((keyCode == 77) || (keyCode == 462)) {
        displayMenu();
    }
}
document.addEventListener('keydown', processKeyPress);
  
   我使用'display:table'作为外部div(hdiv),使用'display:table cell'作为内部div(htxtdiv)。即使“云DVR录制”文本是水平居中的,但它不是垂直居中的。
  
  
   下面是截图。
  
  
   
    
   
  
  
  
  
   有人能帮我解决这个问题吗?