Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to center div height of video in html page

Posted on 2014-09-30
3
Medium Priority
?
213 Views
Last Modified: 2014-10-08
I was able to center a div which contains a <video> but I am also trying to center the video tag as far as height is concerned.  So, how do you center the height in the middle of your page?
0
Comment
Question by:VBBRett
  • 2
3 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 40352436
Well if you are using <video> then you are supporting  modern HTML5 browsers that should also be supporting the CSS calc() function and the viewport relative units of neasure so you should be able apply what is on this page that contains practical examples using calc()

Cd&
0
 

Author Comment

by:VBBRett
ID: 40352534
Hi COBOLdinosaur, I attempted to use the example but for some reason was unable to get to work.  Here is my markup as of yet:

<!DOCTYPE html>
<html>
<head>
    
    <style type="text/css">
        html {
    position: relative;
    min-width: 1024px;
    min-height: 768px;
    height: 100%;
}

        #videostyle {
            margin-left:auto; 
            margin-right:auto;
            margin-top:auto;
            margin-bottom:auto;
            height:480px;
            width:854px;            
        }
    </style>
    <title>Test Page</title>
</head>
<body>
    <div id="videostyle">
        <video id="vidintro" autoplay="autoplay" width="854" height="480" contenteditable="false">
            <source src="web.mp4" type="video/mp4" />            
            Your browser does not support the video tag.
        </video>
    </div>
    <script type="text/javascript">
        var vid = document.getElementById("vidintro");
        vid.controls = true;    
    </script>
    <script type="text/javascript">
        var vid = document.getElementById("vidintro");
        vid.onended = function () {            
            location.href = "http://www.testsite.com";
        }
    </script>
</body>
</html>

Open in new window

0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 2000 total points
ID: 40352640
I don't see where you are applying anything that would center vertically, and do analysis of the page we really need a link so we can use diagnostic tools.

Cd&
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question