Positioning Text in a Responsive Video Background

Trying to center text within a video has been a challenge for me. Even after removing the header container, achieving the desired results is still possible, which works fine with me. However, I'm still struggling with getting this text centered!

<div class="video-container">


    <video class="video" preload="true" autoplay = "autoplay" loop = "loop">
            <source src="nyc.mp4" type="video/mp4"/>

    </video>
    <p class="center-block quote"> Test </p>

Styling:

.video-container {

position:absolute;
top: 0%;
left: 0%; /*centers the video */
height: 100%;
width: 100%;
overflow: hidden;

}



video {
margin-top:50px; /* gap b/w navbar and header */
position:absolute;
z-index: -1;
opacity: 0.78;
width: 100%;
margin: none;
padding: none;
}

Answer №1

One of Bootstrap's convenient features is the helper class called .text-center

Give this a shot:

<div class="video-wrapper text-center">

Answer №2

There is a screenshot below: View the print screen here

<!DOCTYPE html>
<html>
<body>
<style>
 .center-block{text-align: center;}
.video-container {

position:absolute;
top: 0%;
left: 0%; /*centers the video */
height: 100%;
width: 100%;
overflow: hidden;

}



video {
margin-top:50px; /* gap b/w navbar and header */
position:absolute;
z-index: -1;
opacity: 0.78;
width: 100%;
margin: none;
padding: none;
}
</style>
<div class="video-container">


    <video class="video" preload="true" autoplay = "autoplay" loop = "loop">
            <source src="nyc.mp4" type="video/mp4"/>

    </video>
    <p class="center-block quote"> Test </p>
</div>

</body>
</html>

Answer №3

Here is a useful tip:

<p class="center-block quote" style="text-align:center;"> Test </p>

Make sure to also include the following code snippet:

.video-container {

position:relative;
top: 0%;
left: 0%; /*centers the video */
height: 100%;
width: 100%;
overflow: hidden;

}

Answer №4

.custom-video video{ 
  position: fixed;
  top: 100%;
  left: 100%;
  min-width: 100%;
  min-height: 100%;
  width: auto;
  height: auto;
  z-index: -100;
  transform: translate(-100%, -100%);
}

.custom-video{  
  justify-content: centre;
  width: 100%;
  height: 100%;
  text-align: centre;
}

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

I utilized Bootstrap to validate the form, however, despite the validation, the form is still able to be submitted. What steps can I take to

I have implemented form validation using Bootstrap's 'needs-validation'. However, I am facing an issue where the form still gets submitted even when the validation fails. What I want is for the form submission to be prevented if the validati ...

aligning adaptable grid on the screen

Is anybody able to assist me in vertically centering the responsive matrix below so that it is equidistant from the left and right edges of the screen (parent element has a width of 100%)? Any help would be greatly appreciated. Here is my code: <!DOC ...

PHP data is not displayed by Ajax

I seem to be encountering a bit of trouble. I am attempting to utilize ajax to retrieve data from a PHP server, which in turn fetches it from a MySQL database, and then display it within a specific HTML tag location. However, for some unknown reason, nothi ...

Modifying the small-dialog identifier in the Magnificent Popup

I recently encountered an issue while trying to change the ID name of the small-dialog in the Magnificent Popup JQuery Plugin. After making the necessary CSS adjustments to accommodate this change, the dialog box stopped functioning properly. I am now seek ...

Is there a glitch in MacOS Firefox's background-size:cover feature? Any tips on how to work around it?

Here is an example link to see the issue: I've noticed there is a strange empty 1px line at the bottom of the box. It seems to occur when Firefox tries to resize an image with an odd number of lines. Has anyone else encountered this problem? If so, h ...

Can you explain the process of selecting a SubMenu Item that is a hover link in IE using C# and Selenium?

I have been scouring various topics on Stack Overflow and other platforms for days in search of a solution to my problem, but so far, I have had no luck. I am facing an issue with automating a website using C# Selenium where Webdriver is unable to click on ...

Ways to identify the active anchor within an li element

Below is the code snippet I am currently working with: <li> <a href="<?php echo base_url()?>home/promos/call" class="promo-call active-call"></a> </li> <li> <a href="<?php echo base_url()?>home/promos/text ...

Delete all HTML functionalities

Is there a way to strip HTML functions when using a text area so that the content shows as plain text in a new post (div)? For example, if I type "Hello", I want it to appear as "< b > Hello < b / >", showing the whole code. Here is the code ...

Enhancing the visual appeal of HTML code in "view Source" by injecting it using a System.Web.UI.WebControls.Literal

I am currently placing code within a literal in the following manner. ImageItem.Text = string.Format("<div class=\"thumb\"><img src=\"{0}\" width=\"132\" height=\"99\" /><a class=\"more\"> ...

The mobile navigation bar may not display correctly on certain iPhones and iPads

Currently using a custom theme on Prestashop 1.6 where minor changes have been made to the CSS file, focusing mostly on colors and fonts. Interestingly, the mobile menu functions flawlessly on Android devices that were tested. However, some Apple devices s ...

When an HTML element extends beyond the screen's right boundary, it becomes truncated

My website utilizes a table to showcase some data, but there's an issue when viewed on smaller screens. The table gets cut off and not all the content is visible. Even after scrolling completely to the right, the rightmost field remains barely visible ...

Creating a QR code using base64 in PHP and HTML

My PHP code generates QR codes in WordPress, but some tax roles require the code to be in base64. I need help converting my code to work with Hexadecimal Encoding 64 and utf8. Here's a snippet of my current code: <?php $barcodetype = ...

What is the best approach for rendering HTML on a page both initially and dynamically as it is updated, given the heavy utilization of ajax?

One challenge faced by many web applications today is how to efficiently reuse html templates without redundancy when initially rendering a page and adding new content. What is the most effective approach for this? One option is to render the HTML page ...

Adjust the background color of alternate elements

I am looking to customize the background colors of every other element within the structure provided below: <div class="dets"> <div>Simple Layout</div> <div>Few Pictures/Links</div> <div>Element Uniformity</div> ...

Modifying the title of a webpage with a Bootstrap design

As a newcomer to HTML/CSS, I recently utilized a Bootstrap theme from Themezy to build my personal website. The template includes a navigation bar with tabs labeled Top, Work, Portfolio, and Contact. I felt the need to change Top to About, so I replaced ...

The function designed to create in-line TailwindCSS classNames may work inconsistently in React and NextJS environments

Currently, I am utilizing TailwindCSS to style a web application. One frustrating aspect is that when attempting to add before: and after: pseudo-elements, it must be done individually. For instance, take the navigation drop-down button styling: <span ...

I wish to substitute a form field with a different one once the value of another field matches a specific condition

The issue I'm facing is that the field disappears once "US" is chosen and does not revert back to the options when another choice is made. teacher_signup.html {% block content %} <h2>Sign Up As Teacher</h2> <form method="post> ...

An overflow occurs due to the grid column gap

After testing CSS display: grid, I noticed that the grid-column-gap: 10px; property is causing the parent container to break. This makes the green area in my code smaller than the grid area itself. It seems like box-sizing: border-box; doesn't have a ...

Concealing tooltip when button is clicked using jQuery

I am facing an issue where the tooltip does not hide on button click. Below is the code for the button in question: <button class="btn btn-outline-inverse ajax_addtocart additems ...

HTML Input Hidden : Completely Concealed

I have been working on creating a 'captcha' for my website, and this is the code I am using: <form class="captcha" method="post"> <label><?php echo $captchas ?></label><br> <input name="captcha" /> <input t ...