Solved

How to center div height of video in html page

Posted on 2014-09-30
3
209 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

623 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