Hover Effects without Continuous Looping Videos

I've successfully created a div with a video as the background, however, the video is only visible when hovering over the div.

Everything is functioning correctly and here is the CSS code I'm using:

.row .col .background-inner{
    background:url('https://meivcore.pt/novo/wp-content/uploads/2017/11/mecanica-small-filtro.jpg');
}

.row .col .background-inner .video{
    display:none;
}

.row .col .uncoltable:hover .video{
    display:block;
}

When I hover over the div, the video plays on loop, which is expected. Is there a way to stop this looping behavior? Ideally, I would like to hover over the div, watch the video play once, and then stop on the last frame.

Answer №1

One of the primary reasons a HTML5 video tag will continuously loop is due to the presence of the loop attribute within the tag itself.

To easily demonstrate this difference in markup, I created a brief codepen showcasing it:

https://codepen.io/example-pen/pen/ZQPPaq

The distinguishing factor between the two examples lies in the addition of the loop attribute at the end of the line below:

<video width="480" height="360" controls autoplay loop>

Useful resources: MDN - HTML Video Tag

Remember: It can be challenging to provide a conclusive answer without a practical demonstration of the issue.

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

Having trouble with your JQuery code?

I created this program to toggle the visibility of a message on a webpage. The hiding and unhiding functionality is working, but I am encountering an issue when trying to change the text on the button. Here is the HTML Code: <!DOCTYPE html> < ...

Is there a way to align this button perfectly with the textboxes?

https://i.sstatic.net/ODkgE.png Is there a way to align the left side of the button with the textboxes in my form? I'm using bootstrap 3 for this. Here is the HTML code for my form. I can provide the CSS if needed. Thanks. h1 { font-size:83px; ...

The presence of element hr within element ul is not permitted in this particular context. Additional errors from this subtree will not be displayed

Here is the code snippet that I have been working on recently: Originally, I had an "hr" tag directly included in my code which worked perfectly but caused a site validation error. So, I made some changes to the code as shown below: <nav> ...

What is the best way to create an iframe positioned above a navigation bar using CSS?

When I click the button, an iframe pops up on my website. However, the navbar overlaps it unless I scroll down. You can view my practice site at: This is the issue I am facing: https://i.sstatic.net/TKmw7.png Oddly enough, everything looks fine when I ...

Troubleshooting: iOS Web App Splash Screen fails to load

I'm having trouble displaying a splash screen on my web app for iOS devices. Upon launching the app from the home screen, I only see a white screen with no content loading. Interestingly, if I rearrange the meta tags to be below the icons and splash s ...

How do I get the JavaScript If Style Color to function correctly?

Having some trouble with a basic if condition that checks the color of an element... function adjustColorScheme(element) { if (element.target.style.color == "#1abc9c"){ // Leave as is } else { // Do some ...

The advice I received was to avoid using max-width and instead utilize min-width when styling with CSS

With @media screen and (max-width:700px) { Link to image 1 Whenever I use @media screen and (min-width: 700px) { it messes up. How can I adjust it for min-width without causing issues? Link to image 2 ...

Complete the execution of the jQuery function

It may seem like a simple idea - to stop executing a function, just use return false, return, or call on a function like undefined. However, in this case, it's not that straightforward. I'm working on a website project that includes a snake game ...

What is the best method to send the HTML button ID to a Python file through Django?

I have the following HTML code snippet that generates dynamic buttons: {% for i in loop_times %} <button type="submit" class="'btn btn-lg" name="{{ i }}" id="{{ i }}" onclick="alert(this.id)" formmethod="post"><a href="{% url 'button ...

Aligning text in the middle of a div vertically

Visit the Satoshi Faucet Index here I'm attempting to vertically align the text within the four divs containing sat, bit, mBTC, and BTC. I have tried using display:table-cell; vertical-align:middle; on the divs but unfortunately it isn't havi ...

I am having trouble selecting Bootstrap radio buttons on my ASP.NET Core MVC application

My asp.net mvc core web application has the following code to display 2 radio buttons:- <div class="form-group"> <label class="control-label" style="font-weight:bold"> ...

How to position collapsible buttons in Twitter's Bootstrap framework

I have successfully created two buttons on the same line. The second button is collapsible and when clicked, it adds a row of two more buttons to the view. However, the newly collapsed row of buttons appears aligned with the second button. I would like th ...

Make sure to include the !important declaration when setting the fill property for

When attempting to apply !important to the fill property of an SVG file, I'm encountering issues with the syntax. Despite my efforts, the !important directive is not being correctly applied to the fill property, resulting in the circle element renderi ...

Next.js encountering page not found error due to broken link URL

Currently, I am working on implementing a login system in next.js. In the login page, I have included a Link to the Register page using the Link href attribute. However, every time I click on that link, it displays a message saying "404 page not found." Al ...

What could be causing the favicon in my Next.js application to not function properly?

My favicon doesn't seem to be working properly. I've saved the favicon file as favicon.ico in the /public directory and have included a reference to it in the <Head> section of my pages (which are located in the /pages directory), but it s ...

Chrome's CSS columns cannot contain iframes without causing them to escape their

I'm currently attempting to incorporate Iframes within a 3-column grid. HTML <div id="blogPosts"> <div class="blogPost"> <iframe width="100%" src="https://www.youtube.com/embed/YqeW9_5kURI" frameborder="0" allowfullscre ...

Tips for designing a CSS border that remains consistent in size throughout

I'm trying to figure out how to adjust my code so that the border surrounding my text stays in position and changes size when I input longer text. Here is the code I'm currently working with: <h1 id="result" style="color:black; font-family: B ...

What's causing all my carousel slides to stack on top of each other instead of presenting in a

Whenever I click 'run' or 'preview' in a browser, specifically using Chrome, all three slides are displayed stacked from 1 to 3 in a static view. They do not toggle through each slide as intended. This issue only occurs on Codeply, a p ...

Interactive Dropdown Menu Generation

Despite my expertise in programming languages like MySQL, PHP, JavaScript, jQuery, HTML, and CSS, the current issue I am facing does not relate to any of these. It essentially comes down to three key aspects: Creating a menu layout with clickable link op ...

Guide: Writing code that caters to different types of media in React using Material-UI

After reviewing the documentation, I believed that the optimal solution in later versions of material-ui was to use useMediaQuery, but unfortunately, I am unable to implement it correctly. My objective is to hide a menu when the page is being printed, so I ...