Styling the video to be both centered and resized within the space between the header and

I'm struggling to center and resize the video.js on my page. I want it to be responsive and never go beyond the boundaries of the headers and footers. My goal is to replace the black square with a larger video, but still fit within the header and footer. Ideally, I'd like the video.js control bar to align exactly with the footer with the same width. Can anyone help me find a good solution? Thank you!

https://i.sstatic.net/lrkoo.png

html:


                <!doctype html>
                <html>
                <head>
                <meta charset="UTF-8">
                <title>title</title>
            <link href="//vjs.zencdn.net/6.6.3/video-js.min.css" rel="stylesheet">
            <script src="//vjs.zencdn.net/6.6.3/video.min.js"></script>
            <script src="http://reference.dashif.org/dash.js/nightly/dist/dash.all.min.js"></script>
<script src="https://github.com/videojs/videojs-contrib-dash/releases/download/v2.9.1/videojs-dash.min.js"></script>

                <style type="text/css">

           .video-js .vjs-current-time { display: none; }
           .video-js .vjs-time-divider { display: none; }
           .video-js .vjs-duration { display: none; }
           .video-js .vjs-progress-control { display: none; }
           .video-js .vjs-remaining-time { display: none; right: auto;} 

                 body,html{
                    margin:0;
                    padding: 0;
                    background-color: white;
                }   

                * {
                    box-sizing: border-box;
                }       

                .head {
                     position: relative;
                    display: block;
                    padding: 8px;
                    float: left;
                }
                .head:after {
                    content: "";
                    display: table;
                    clear: both;
                }   
                .left {
                width: 75%;
                background-color: #FF5A00;
                }

                .right {
                    width: 25%;
                    background-color: #FFFFFF;
                }

                    img {
                    vertical-align: middle;
                }   

                .cent
                {

                    height:50px;
                    width:50px;
                    background-color:black;
                    margin:auto;
                    position:absolute;
                    left:50%;
                    top:50%;
                    margin-left:-25px;
                    margin-top:-25px;
                }

                    .footer {
                  position: absolute;
                  right: 0;
                  bottom: 0;
                  left: 0;
                  padding: 1rem;
                  background-color: #efefef;
                  text-align: center;
                        font-family: 'titles', Fallback, sans-serif;
                    font-size: 100%;
                    font-weight: normal;
                    letter-spacing: 1px;
                }
                    </style>
                </head>

                <body>
                    <div header="head">
                  <div class="head left">
                <img src="logos.png" alt="logo" height="20">
                  </div>
                <div class="head right">
                <img src="logos.png" alt="logo" height="20">
                  </div></header>
                <div class="cent">
        <video id=tv-video class="video-js vjs-fluid vjs-default-skin vjs-show-big-play-button-on-pause vjs-big-play-centered" controls autoplay preload="auto"></video>
          <script>
          var player = videojs('tv-video');
          player.src({ src: 'video/manifest.mpd', type: 'application/dash+xml'});
          player.play();
              player.on("pause", function () {
                player.one("play", function () {
                  player.src({"type":player.currentType(), "src":player.currentSrc()});
                  player.play();
                });
              });
        </script>
        </div>
                <footer class="footer"><img src="firma.png" alt="logo" height="20"></footer>

                </body>
                </html>

Answer №1

Insights

To start, it is important to mention that there were errors in your source code, particularly in the header tag. I have rectified these issues in the modified code below, along with other enhancements.

I have only preserved the content within the <body> tag since that is the focal point, and I refrained from using your JavaScript due to its reliance on local resources. You are encouraged to adjust the code as needed to achieve the desired functionality, keeping video.js compatibility in mind.

Enhancements

The body now utilizes display: flex; for leveraging the capabilities of flexbox. This facilitates maintaining a consistent layout where the header and footer remain fixed at the top and bottom respectively, regardless of screen size.

The header has been updated to utilize the <header> tag, akin to how <footer> is employed for the footer section. Additionally, it incorporates display: flex; to eliminate the need for float on elements.

For semantic purposes, the main content is enclosed within a <main> tag, while retaining the .cent class for flexibility. The associated CSS properties include flex for occupying space and align-self for specifying behavior within the body context (although the latter is optional).

The video now spans 100% width and height available, adjusting proportionally for display based on aspect ratio considerations.

In cases where the screen ratio does not align with the video's 16:9 dimensions, default behavior involves proportional scaling resulting in black bars added to either vertical or horizontal sides.

Code Snippet

* {
  box-sizing: border-box;
}

body,
html {
  margin: 0;
  padding: 0;
  height: 100vh;
  background-color: white;
}

body {
  display: flex;
  flex-direction: column;
}

img {
  vertical-align: middle;
}

.header {
  display: flex;
}

.head {
  padding: 8px;
}

.left {
  width: 75%;
  background-color: #FF5A00;
}

.right {
  width: 25%;
  background-color: #FFFFFF;
}

.cent {
  position: relative;
  flex: 1 1 auto;
  align-self: stretch;
  background-color: black;
}

.video-js {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

.footer {
  padding: 1rem;
  background-color: #efefef;
  text-align: center;
  font-family: 'titles', Fallback, sans-serif;
  font-size: 100%;
  font-weight: normal;
  letter-spacing: 1px;
}
<!-- Content of the <body> tag -->
<header class="header">
  <div class="head left">
    <img src="logos.png" alt="logo" height="20">
  </div>
  <div class="head right">
    <img src="logos.png" alt="logo" height="20">
  </div>
</header>

<main class="cent">
  <video id="tv-video" class="video-js vjs-fluid vjs-default-skin vjs-show-big-play-button-on-pause vjs-big-play-centered" controls autoplay preload="auto"></video>
</main>

<footer class="footer">
  <img src="firma.png" alt="logo" height="20">
</footer>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Maintain the color of a Bootstrap 4 dropdown link even when it is open by incorporating hover

Currently, I am utilizing bootstrap 4 to create a menu that includes dropdown items. The issue I am facing is that when hovering over a dropdown link, the background color changes and the dropdown opens. However, as soon as I move the mouse to select one o ...

Tips for customizing Bootstrap theme color schemes in a React/Redux application that has been bootstrapped

As a newcomer to REACT, I am facing an issue with changing the theme colors in my freshly bootstrapped react application. I have gone through some solutions suggested by others but none of them seem to work for me. My entry point looks like this: import ...

What is the best way to display a web application on IE8 when compatibility mode is enabled, even though the application itself does not support compatibility mode?

Although I've looked for answers on stackoverflow and other sources, none of them seem to work for me. My application doesn't support Internet Explorer compatibility mode, but the client workstations have it enabled by default. I've tried v ...

Guide to designing a Bootstrap footer that appears only at the bottom of the page and not at the top

I am facing a challenge with my website where some pages have a lot of elements causing scrolling, while others have only a few elements without scrolling. My goal is to have a footer that stays at the bottom of the page regardless of the page size. The f ...

In this scenario, why is the `position: fixed` property anchored to the document rather than the viewport?

I have a gallery set up with a custom lightbox feature that I designed. The lightbox is styled with position:fixed and top:0, so theoretically it should stay in the same position regardless of scrolling. However, I am experiencing issues where this is not ...

I am looking to incorporate a dropdown menu into an HTML form that displays the upcoming four or five Saturdays

Looking for a way to incorporate a dropdown feature in an html form that will display the next four upcoming Saturdays. The purpose behind this is to allow individuals signing up to select which of the upcoming Saturdays they would like to visit our establ ...

Adding mat-icon dynamically to divs using Angular's renderer2

I'm currently working on a project that involves a lot of HTML divs. I've already created some static divs using renderer2. static HTML (not dynamically generated) example of desired result using renderer2 <div class="time-rowss clearf ...

Question regarding the manipulation of attributes in Jquery

I'm a beginner with jQuery and struggling to find a solution for my issue. I have implemented jQuery easytooltip on some SVG elements in my website, which is working well. However, I need to dynamically change certain attributes of the tooltip when ne ...

Set the value to reset in the input box

Aim I am attempting to develop a button that, when clicked, resets each individual's values back to their original input values. You can find a demonstration of this in Codepen: http://codepen.io/coryk/pen/QEGrXp Issue Upon clicking the reset but ...

Problem with CSS/SASS dropdown navigation bar

Having trouble with a design issue, I have successfully recreated the Twitter navigation bar and now I want a dropdown menu to appear when hovering over the 'settings' text. However, I'm facing difficulties as the overflow is hidden in the n ...

The JavaScript Top Slide Down effect is malfunctioning

Every time I press the "More" button, I expect some forms to pop out but nothing happens. Can someone please assist me with this issue? <body> <!--Hero Image--> <div class="hero-image"> <div class="hero ...

Struggling with css margins and div image constraints, seeking guidance and tips for resolution

Struggling with creating a dynamic gallery that works smoothly in jsfiddle but encounters multiple issues when integrated into WordPress. The main problem is the excessive stretching of margins between image titles and meta-data, leading to misalignment an ...

Use jQuery to modify and update specific field within a while loop

I am facing an issue with updating the quantity in my shopping cart. The data is retrieved from a database and stored in a session within a while loop. The problem occurs when I try to update the quantity using the provided code, as it updates all the fiel ...

What is the best way to determine the value of margin-left in inline CSS using jQuery?

Here is the code snippet I am working with: <div class="ongoing" style="width: +728px; margin-left: +12480px"> I need to extract the value of the margin-left property for scrolling purposes. The technique I used to retrieve the width value does no ...

Getting the value of a CSS Variable from Radix UI Colors with Javascript/Typescript: A step-by-step guide

Currently, I am attempting to dynamically retrieve the Radix Colors values in JavaScript. The reason for this requirement is that I generate these colors based on user input, resulting in values that are variable. As a result, I cannot hardcode the values. ...

Achieving a stacked arrangement of divs upon click-through using only pure JavaScript

http://jsfiddle.net/Zgxv9/ In the example provided in my fiddle, the div elements return to their original positions when clicked. However, I am looking for a solution where the last clicked div always remains on top. This is my current code: function di ...

Adjust the content division to be 100% in height, while accounting for the changing height of the

I'm currently utilizing Bootstrap 4 and have a rather intricate footer: https://i.sstatic.net/QGbeO.png ...that dynamically adjusts its height. Since this is a PHP application, the content in the center of the screen is subject to change. When the c ...

Which HTML tags can be activated with JavaScript to be interactive?

I'm currently diving into the world of JavaScript and one of the initial code snippets I've encountered is onclick. So far, I've seen it utilized in form buttons like this: <input type="button" onclick="checkName()" value="Check name" / ...

Automatically refreshing the canvas whenever the value of an HTML element is modified in Javascript

Below is the javascript code that is relevant <script> $.fn.ready(function() { var source = $('#source').val(); Meme('url1', 'canvas','',''); $('#top-line, #bottom-li ...

Dynamically populate select options using Spring Boot Ajax technology

Hey everyone, I need some help with populating a select tag with a list of objects in JavaScript. Here's an example of the code: @RequestMapping(value="/getAllIndustries") @ResponseBody public List<IndustryModel>getAllIndustries() { return ...