unable to enforce max-height using bootstrap

Hello everyone, I have a website built using Bootstrap and I've created a simple header file that includes styling for the navigation bar, fonts, and layout. However, I'm facing an issue with making a video span 100% of the browser width with a maximum height of 800px. Despite my efforts, the video is not responsive and there is white space on the sides. Any assistance in achieving a centered, responsive video would be greatly appreciated! Below is a snippet of my index file:

<?php require_once('header.php');?>
<style>
.videoContainer {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;
  height: 800px; 
  overflow: hidden;
  margin-top: 50px;
}
.videoContainer video {
  min-width: 100%; 
  max-height: 800px; 
  width: auto;
  height: auto;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
}
</style>

<body>
    <div align="center" class="videoContainer">
    <video src="Balloon.mp4" autoplay="true" loop="true"></video>
    </div>
</body>

Answer №1

To make sure your video fits the entire width of the viewport when using bootstrap, wrap it inside a container-fluid element. This will give the video full-width view (check documentation). Here's an example:

 <div class="container-fluid">
      <video src="Balloon.mp4" autoplay="true" loop="true"></video>
 </div>

Next, add this to your CSS:

 div video {
     height: 800 px;
 }

Answer №2

To ensure your video spans the full width of your div, avoid setting a specific height for the video itself. Videos will naturally maintain their aspect ratio, meaning if you set a height, the width will adjust accordingly. The optimal approach is to set the height for the surrounding div container and allow the video to expand to 100% within that space.

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

Issue with Bootstrap z-index preventing element from being clickable. In search of a solution to properly layer elements behind one another

Encountering an issue with the accordion on my website - only the first item opens. The culprit is not the data-target. If I disable CSS in my code, everything works fine... Upon further investigation, I discovered that the problem lies with the Z-INDEX p ...

Creating a Select component in React without relying on the Material-UI library involves customizing a dropdown

Is there a way to achieve a material UI style Select component without using the material UI library in my project? I'm interested in moving the label to the top left corner when the Select is focused. export default function App({...props}) { retu ...

Bootstrap revamps dropdown menu code into a convoluted mess

I recently started working on a project with the Material Design theme from for a CodeIgniter application. However, I've encountered an issue with the dropdown functionality. It seems that Bootstrap is altering the original code, transforming it from ...

Using the MVC framework, create a hyperlink with custom CSS styling by

Having trouble getting a specific class to override the default styles for a:link @Html.ActionLink("Back to List", "Index", null, new { @class = "htmlactionlink" }) CSS a:link, a:visited, a:active, a:hover { color: #333; } .htmlactionlink { co ...

Rows in the table are distinguished by varying colors

Is it achievable to replicate this design solely using table CSS style? I am able to assign different colors to even and odd rows, but my goal is to achieve something like this (just the colors): ...

What steps should be taken to incorporate a user input space similar to the one found in the Wordpress new post section

I am looking to incorporate a user input section on my website similar to the one found in WordPress for creating new posts. I would like this area to have all of the same tools available, such as adding hyperlinks, bolding text, and uploading images. Ca ...

"Within the boundaries of two tags, eliminate any spaces when using the display property set

I'm a bit confused about the behavior of display:inline-block. I noticed that when I use inline-block, it displays content in a smaller space across two tags. However, when I switch to using float: left, everything works fine. Does anyone have an ide ...

Issue with iOS iframe scrolling - unable to scroll as expected

On iOS devices like the iPad and iPhone 6, scrolling doesn't seem to work as intended. Instead of the iframe scrolling, it's the 'body' that is moving. Javascript $(document).on(clickHandler, '#content a', function(){ href ...

Div with fixed positioning experiencing glitching until reaching a specific height

I've been struggling to resolve an issue with a script that is supposed to scroll down with the page and stop at a specific height. However, right before it reaches the desired point, it temporarily disappears and then reappears. For reference, here& ...

Adding animation effects using CSS and/or jQuery

Are there any Jquery plugins or CSS codes available to achieve similar effects as seen on the following pages and , without utilizing webGL?... ...

Attempting to implement a button element in a reactstrap card to toggle the visibility of the card's text

Is there a way to implement a toggle feature for the card text ({card.description}) by clicking on the detail button? Do I need to use a state function or is there a simpler method using collapse? I would like the card image and title to always be displaye ...

Responsive design is key in ensuring that Bootstrap columns adjust accordingly

I am attempting to create a responsive block in the center of my webpage with the help of Bootstrap. However, I am having trouble getting the columns to respond correctly to my bootstrap setup. Can anyone point out what I might be doing wrong? <lin ...

Trouble centering a list within a parent div using CSS

Even though this issue seems straightforward and many others have asked similar questions on the site, I find myself stuck after reading through several solutions and attempting various fixes. Why is this happening? My problem involves centering a navigat ...

Is there a way to manipulate the placement of an image within a div using CSS?

Teaching myself HTML has been quite the journey. Right now, I'm in the process of building a website purely for its aesthetic appeal, and I seem to be hitting a roadblock with the CSS/div element. As of now, it appears like this. When the h1 is remove ...

Troubleshooting: Why isn't External CSS Functioning Properly in Broadleaf

I have encountered a question regarding the use of a custom email template in broadleaf. It seems that I am unable to apply an external CSS file and can only use inline styles. Is this normal behavior, or am I missing something? Below is how I am attempti ...

How can I eliminate padding from events in FullCalendar's timeGrid view?

Is there a way to remove the padding from an event when the calendar is in 'timegridview'? Users are taking advantage of the empty space created, allowing them to bypass a blocked time slot. I currently have it set so that clicking on an event d ...

Creating a visually appealing website layout using HTML and CSS to align DIV

I'm having trouble with the CSS aspect of my portfolio website design. I'm trying to create a layout like this: Here's what I have so far: body { margin: 0; padding: 0; } .menu { height: 100vh; width: 380px; background-color: # ...

Utilizing JavaScript to assign a CSS class to an <li> list item

I am working on a page that includes a menu feature: https://jsfiddle.net/dva4zo8t/ When a menu button is clicked, the color changes and I need to retain this color even after the page is reloaded: $('[id*="button"]').click(function() { $( ...

How can I align rectangles with different heights to display side by side using Javascript?

Currently, I am designing a press page for a website where the headlines/articles are displayed in rectangles. To achieve this layout, I am using the following CSS: .press-blocks{ column-count: 4; column-gap: 2em; padding-left: 10%; padding ...

Tips for presenting HTML source code with appropriate tag coloring, style, and indentation similar to that found in editors

I need to display the source code of an HTML file that is rendered in an iframe. The source code should be shown with proper tag colors and indentations similar to editors like Sublime Text. https://i.stack.imgur.com/IbHr0.png I managed to extract the sour ...