Black Friday 2026 50% off every plan Our biggest deal of the year on #1 Joomla products.
Ends in 12d 07h 31m 25s
Claim 50% off
Staff replied SP Page Builder

How to create a custom css class for video

Asked by Aldus 1 year ago Last activity 1 year ago

Hi,
I need to create a custom css class to show video on intere page.
I make this css code in my custom.css file but there is an error.
I think that error is in row "background-image"...
In fact if I insert the class video_1 it doesn't recognize it

.com-sppagebuilder .video_1   { 
  background-image: url('https://www.xyz.it/media/videos/2025/06/05/my_video.mp4');
  background-size: cover;
  background-attachment: scroll;
  background-position: center;
  }

Please, can you tell me a correct syntax?

If there was the possibility of a single css code to see the video in the entire page (instead of for a single section) it would be perfect for me and I could do without creating a css class

Thank you

1 reply

Atick Eashrak Shuvo Staff

Hi,

Thank you for your message.

Unfortunately, CSS does not support using video files (.mp4, .webm, etc.) with the background-image property — this property only works with image formats such as .jpg, .png, .gif, etc. That’s why your custom class with background-image: url('...my_video.mp4') is not working — it's simply not valid CSS syntax.

Key Points:

  • background-image only accepts image formats, not video.
  • It’s not possible to display a video using CSS alone. A <video> element is required in the HTML to play videos.

There is no way to add a background video purely via CSS.

Log in to reply.