Solved

How to center div height of video in html page

Posted on 2014-09-30
3
202 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 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
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…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now