What is the best way to maintain the position of an overlay on screen when dealing with multiple resolutions?

I'm struggling to find a solution that works for me - I could really use some assistance. My CSS skills are not up to par...

Currently, I have a video embedded in a web page with a text overlay. The problem arises when the content is displayed on a large screen; the overlay appears in the wrong position.

What would be the most effective approach to resolve this issue? Should I adjust the positioning of the overlay using CSS or utilize panels? Below is the code snippet...

CSS:

.video {
        position:absolute;
        bottom:0px;
        left:0px;
        width:50%;
        height:80%;   
    }

    #vidPlayer {
            position:absolute;
            bottom:-100px;
            left:0px;        
            width:100%; 
            display:block;
            z-index:99;
        }

    .overlayLabel {
        font-size:xx-large;
        font-weight:bolder;
        font-style:italic;
        color:antiquewhite;
        position:absolute;
        text-align:center;
        bottom:50px;
        left:100px;
        width:900px;  
        border:2px solid red;      
        z-index:2147483647;
    }

HTML:

<div>
    <article class="video">      
        <video id="vidPlayer" title="My Video" >
            <source src="Media/MyVideo.mp4"  type="video/mp4" />
        </video>
        <asp:Label ID="lblWinner" runat="server" Text="Test Overlay" CssClass="overlayLabel"></asp:Label>      

    </article>
</div>

The modifications I made successfully addressed the following issues:

  • Correctly displaying an overlay with dynamically set text over the video
  • Ensuring the video is the correct size
  • Positioning the overlay accurately regardless of screen size

    .video {
        position:relative;
        width:100%;
        height:auto;   
    }
    
    #vidPlayer {
        z-index:99;
        position:relative;     
        width:100%; 
        height:100%;
        }
    
    .overlayLabel { 
        z-index:2147483647;
        position:absolute;    
        background-image:url("Images/test.png");
        -webkit-transform: rotate(13deg);
        -moz-transform: rotate(13deg);
        -ms-transform: rotate(13deg);
        -o-transform: rotate(13deg);
        transform: rotate(13deg);
        font-size:xx-large;
        font-weight:bolder;
        text-align:center; 
        color:black;       
        bottom:44%;
        left:37%;
        width:30%; 
        height:24%;      
    }
    

Answer №1

Ensuring your design is adaptable to different screen sizes is crucial.

One approach is implementing CSS media queries, which allow for the creation of specific style rules based on varying resolutions (widths) to adjust label and text placement. Check out this resource for more information.

Alternatively, you can utilize responsive units such as %, vh, vw in place of px for better positioning flexibility.

In my opinion, using media queries is the way to go.

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

Is there a way to grant access to a website requiring a client authentication certificate without actually having the certificate, but instead using a virtual machine that contains the necessary certificate?

Let's consider the following situation: A website requires a client authentication certificate, which we cannot provide to everyone. The website must be protected with this certificate and cannot be changed. To clarify: Website X (not created by me) ...

Can you explain the distinction between [att|=val] and [att~=val] in css?

Could someone help me differentiate between the [att|=val] and [att~=val] attributes in CSS? I'm having trouble grasping the concept. Thank you! ...

"Enhance Your Slide Up/Down Menu with a Unique Hover Effect in jQuery

HTML: <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="navigation_desktop"> <div class="button_desktop_01">1.0 Main Menu <div class="SlideItem ...

What is the best way to continuously compare two date variables every minute using Javascript?

In my script, I have two date variables - one representing the current time and the other two minutes later. My goal is to compare both values every minute and trigger a function when the current time is greater than or equal to the latter time. Unfortun ...

Updating the content of a Telerik RadEditor using Javascript/jQuery

I am currently facing a challenge in manually cleaning the HTML of a Telerik RadEditor using Javascript. Despite my efforts, I am struggling to find the appropriate location to store the value in order for it to be saved during post back. Below is the Jav ...

How can I vertically align text in React-bootstrap Navbar Nav-items?

I have been struggling to find a solution to my problem without resorting to custom CSS classes. I'm wondering if it's possible to achieve what I need using only flex classes. Here is the code for a simple navbar component: <Navbar bg ...

What is a method to raise the height when scrolling down without reducing it when scrolling up?

For my One Page project, I want a DIV element to increase in height when scrolling down, but maintain that increased height when scrolling up. Currently, I am utilizing JQuery with the code snippet below: $(function(){ $(window).scroll(function() { ...

Message within the boundary of the input field

Click here to view the image It would be great to have the text "text name" displayed on the border of the input box. Here is the HTML code - <input type="text" id="text creator" class="form-control" placeholder="text creator" na ...

Changing the position of an image can vary across different devices when using HTML5 Canvas

I am facing an issue with positioning a bomb image on a background city image in my project. The canvas width and height are set based on specific variables, which is causing the bomb image position to change on larger mobile screens or when zooming in. I ...

Translate CSS into JavaScript while maintaining selector understanding

I am interested in developing a tool that can read a .css file and generate a function that will accept an array of class names as input and output the corresponding styles for an element with those classes, represented as a JavaScript object. This tool wo ...

What is the best way to enlarge an element when scrolling downwards within the element?

I am looking to create a div that dynamically adjusts its height based on the user's scrolling behavior. The goal is for the div to expand to the very top as the user scrolls downward, and stop when it reaches 70% of the container/parent element. Is t ...

Problem arises with table nth-child selector following the addition of grid-gap

Our current table looks like this: https://i.sstatic.net/eUyBB.png The first row has a background color and the second row is white - which is correct. Now I would like to align the attributes to the right. I added the following code to the table: .table ...

Interacting with a .aspx web method using jquery.ajax

Previously, I had successfully implemented the code below in a proof of concept without using variables and hardcoding all the values. However, when I introduced variables to prepare for utilizing this channel, the functionality stopped working. There migh ...

The web service consistently provides a combination of XML and JSON formats. Is there a way to convert it to solely

I have been assigned a project where I need to create a webservice that strictly returns JSON data. Despite my efforts, the code I've written always returns a combination of XML and JSON response. namespace DotMeTast { [WebService(Namespace = "h ...

Is there a way to remove a specific row from both an HTML table and a MySQL database using CodeIgniter?

Just diving into CodeIgniter and successfully retrieved data from MySQL to display in an HTML table. Now, the challenge is to delete specific rows in MySQL. Imagine a scenario where there are 10 rows in the table, each accompanied by a checkbox, and a Del ...

"Encountering an issue with the insert query when attempting to submit

i am currently working with an html form <form name="booksInput" action="theGamer.php" method="post"> Book Name: <input type="text" name="books"> <input type="submit" value="Submit" name="subBooks"> </form> below is th ...

Using JavaScript/JQuery, change relative or viewport sizes to fixed sizes when the page loads

Wishing you a delightful day. As I work on my website, I find myself relying heavily on viewport units like vw and vh for all measurements such as font size, padding, margin, width, and height. These units provide the flexibility needed to ensure that the ...

Tips for retrieving the element id from a different page using JavaScript

I've been attempting to retrieve an element id from an HTML page on a different page, but none of the solutions I've found have worked so far. For instance, consider the following code snippet from One.html: <input id="a" type="text">< ...

I am encountering issues with setting a background image in Bootstrap 3.1.1 while trying to achieve a par

I'm struggling to add a background image to my bootstrap site. I'm attempting to create a parallax site using stellar.js, and while the site is functional with text on each slide and correct scrolling links, the images just won't load. Despi ...

Is it possible to transform all scripts into a React component? (LuckyOrange)

I am currently working on converting the script for a specific service (http://luckyorange.com/) into a component. The instructions say to place it in index.html within the public folder, but that appears to be insecure. I'm uncertain whether this tas ...