Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

HTML/CSS: Make text overlay but keep video responsive to mouse events (Elementor)

we’re kinda new to this whole webpage coding stuff and are currently working on setting up our own wordpress page with custom html/css via wordpress/elementor (but still in the free version, not pro).

We made a video autoplay and react to hover mouse events and mouseclicks, but as we tried to put a text overlay over the videobox with a .overlay class, the overlay class would cover the whole video and the actual video wouldn’t react to our mouse. The goal is to display the text over the video, whilst the video itself keeps playing and pausing when hovering over it.

We’re using the HTML function of the Elementor plugin.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Any help/advice would be much appreciated.

Here is what we got so far (and yes, we’re newbs when it comes to coding, sorry for the messy code I guess):

<style>
    .Maus {
        cursor: pointer;
    }
    
    .overlay {
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
        font-family: Times New Roman;
        font-size: 22pt;
        line-height: 22pt;
        text-align: center;
    }
</style>

<div class=Maus>
    <div onmousedown="openInNewTab('https://private.com/video/');">

        <video loop="this.play()" onmouseover="this.play()" onmouseout="this.pause();">
    
        <source src="https://private.com/video.mp4" type="video/mp4">
        </video>
        
         <div class=overlay>
                <p>
                lorem ipsum
                </p>
             
        </div>
        
    </div>
</div>

<script>
    function openInNewTab(url) 
     {
        window.open(url, '_blank').focus();
        }
</script>

here is a screenshot of it:

videofile in elementor widget with text

Tried messing around with the z-index, but failed as elements were overlapping the text so it was behind the video.

>Solution :

You can add pointer-events: none; to make an element let mouse actions "go through it" (to the element behind it)

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading