Achieving successful integration of an overlay on a video with the combined powers of Bootstrap and Angular 6

Currently, I am utilizing Angular 6 and Bootstrap in an attempt to display an image along with some text on top of a video element. While most of the functionality is working as expected, I am facing an issue with aligning the overlay properly with the video element. Instead of aligning with the video, it seems to be aligning with the entire page. Despite various attempts such as removing col and row classes, adjusting the position of the overlay within the code, and creating custom classes, I have been unable to resolve this issue. It appears that there may be a gap in my understanding preventing me from achieving the desired result after spending a significant amount of time debugging.

Below, you will find the HTML and CSS for the component. Any guidance or suggestions would be greatly appreciated.

#overlay {
  position: absolute;
  /* Sit on top of the page content */
  display: display;
  /* Hidden by default */
  width: 50%;
  /* Full width (cover the whole page) */
  height: 50%;
  /* Full height (cover the whole page) */
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(58, 57, 57, 0);
  /* Black background with opacity */
  z-index: 2;
  /* Specify a stack order in case you're using a different order for other elements */
  cursor: pointer;
  /* Add a pointer on hover */
}
<div class="row">
  <div class="col-md-12"></div>
  <div class="embed-responsive embed-responsive-1by1 m-0 p-0">
    <video src="" class="embed-responsive-item" #video id="video" autoplay></video>
  </div>

  <div class="col-md-12" id="overlay" *ngIf="showRobot">
    <img src="https://firebasestorage.googleapis.com/v0/b/ezar-77f5e.appspot.com/o/roboguide3.png?alt=media&token=54655d7b-2cc1-41f4-8c2c-a7855db849f9" alt="" class="w-25" />
    <p>The result is: {{ myString }}</p>
  </div>
</div>

Answer №1

When an element is set to position: absolute, its position depends on the closest parent element with a positioning of relative.

To achieve this, you can try implementing code similar to this:

HTML:

  <div class="row">
    <div class="col-md-12">
      <div class="embed-responsive embed-responsive-1by1 m-0 p-0">
        <video src="" class="embed-responsive-item" #video id="video" autoplay></video>
        <div class="overlay-video" *ngIf="showRobot">
          <img src="https://firebasestorage.googleapis.com/v0/b/ezar-77f5e.appspot.com/o/roboguide3.png?alt=media&token=54655d7b-2cc1-41f4-8c2c-a7855db849f9" alt="" class="w-25" />
          <p>The result is: {{ myString }}</p>
        </div>
      </div>
    </div>
  </div>

CSS:

.overlay-video{
  position: absolute;
  background-color: rgba(58, 57, 57, 0.8);
  top: 25%;
  left: 25%;
  right: 25%;
  bottom: 25%;
  text-align: center;
}

Note that the bootstrap 4 css class .embed-responsive already includes the property position: relative;

DEMO:

https://plnkr.co/edit/8G8SQUia5FAZHpVygD2Q?p=preview

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

Guide to presenting values of nested objects in a template within a child component using Angular2

Currently, I am facing a challenging issue where I receive JSON data from my service class. While I can successfully write the entire object to the console and display root level values, when it comes to nested values I encounter difficulties. I either get ...

Encountering an Assertion Error when attempting to import a custom package in Angular 13

Seeking assistance: I have developed my initial Angular package which offers various services for making HTTP requests to a server and fetching results. Upon importing the service, the webpage ceases to render and displays the following error message: cor ...

Adding a Close Button to a MaterializeCSS Card or Card-Panel

Hey everyone! I'm looking for guidance on how to add a close button (x) to a card or card-panel in MaterializeCSS. While Bootstrap offers an Alert component, unfortunately MaterializeCSS does not have one readily available. Does anyone know of a wor ...

How to include a date in an Angular date input field

I've simplified some logic in this JSFiddle: http://jsfiddle.net/r7vyjg4h/ and it's functioning correctly. The HTML code is as follows: <div ng-controller="MyCtrl"> <div ng-repeat="line in lines"> <div style="display: inline- ...

Guide on building a dynamic grid layout with dual sides?

https://i.sstatic.net/P95ad.png My current code is causing some issues and not displaying as desired. I have included a sample of my code below: <style> .red{ background-color: red; } </style> {% endblock stylesheets %} {% block co ...

I've found that my div element refuses to be centered on the screen unless I explicitly define

Trying to center a div on the page using jQuery has proven to be a bit tricky. It seems that without specifying a height for the div in the CSS, the centering doesn't work as expected. The challenge lies in the fact that the div is meant to resize bas ...

Avoiding overlapping in setTimeOut when using jQuery.hover()

Looking to trigger an effect one second after the page loads, and then every 3 seconds in a loop. When the user hovers over a specific element with the ID #hover, the effect should pause momentarily. It should then resume 2 seconds after the user stops hov ...

elements with a display of inline-block and a fixed body width

My inline-block elements are setting the width of the page, but the header and footer tags are not taking up the full width. Why is this happening and how can I make them span the entire page width? Check out the example here Here's the HTML code: ...

Problem with transitions not working properly in Vue.js.The issue

Experiencing an issue with the Vue.js transition feature. Check out this link for reference. When the transition enters, it works smoothly, but when transitioning out, it's not functioning properly. File: genetic.vue <transition name="slide-f ...

Ways to move Bootstrap 4 navbar list items to the right side?

Is there a way to move the li elements to the right without causing issues with the toggler or navbar? <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet" /> <nav class="navbar navbar-expand- ...

Merging backend code (Java and Python) into HTML for seamless integration

While I have a solid background in back-end coding languages like Java and Python, the task at hand requires integrating this code into a website. The backend code comprises various methods and classes to encrypt text messages using encryption techniques ...

Python: Automate clicking on checkboxes with Selenium

Recently, I've encountered a problem and I'm in search of an answer. Below is some HTML code that I need to work with. My goal is to send a snippet of this HTML to selenium so that it can click on a checkbox. However, I don't want to use the ...

Guide to developing a manual tally counter with recorded logs using HTML and JavaScript

I am currently in need of assistance with creating a manual input counter using the App Script Editor. My website design already includes a single input textbox, a reset button, and a disabled box. What I would like to achieve is that when I enter a numb ...

Half-height rows and columns in Bootstrap 4

Can someone help me create blocks similar to the one shown in the image? The left block should be col-5, while the right block should be col-7. The right block needs to have two rows with a height that is 50% of the left block. Is there a way to achieve ...

The webpage Page.php is failing to display the newly added content

I have a collection of logos on my homepage (index.php) in WordPress, and they are positioned at the bottom just as I intended. However, these logos do not appear on all pages. Even if I add the exact same code to the page.php file in the exact position, ...

Is it possible to alter the HTML structure using JavaScript?

Looking to shift the positions of 2 divs using JavaScript DOM manipulation, all without altering the HTML. <div class="div1"> this should move downwards</div> <div class="div2"> while this should move upwards</div&g ...

What is the best way to showcase several images using Sweet Alert 2?

In the process of developing my Angular 2 application, I have incorporated sweet alert 2 into certain sections. I am looking to showcase multiple images (a minimum of two) at the same time in the pop-up. Does anyone have any suggestions on how to achieve ...

The absence of a meta tag in the Wordpress head section

I keep getting an error from Lighthouse saying that I am missing both the viewport meta tag and description meta tag Does not have a <meta name="viewport"> tag with width or initial-scaleNo `<meta name="viewport">` tag found ...

Transferring information between two pages when a button is clicked in Angular

How can I display hero details on the hero-details page when clicking a button? I'm currently struggling to make it work. When I click the button, the details show up on the hero-list page, but using the routerLink doesn't display the data. I am ...

What is the best way to combine the output values from various Observables into one unified emission in RxJava?

One of my functions takes a DTO object and converts it into an observable that emits the transformed Entity. Here is the function signature: dtoTransformer(dto: DTO): Observable<Entity> I also have another function that returns an Observable contai ...