Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

mobile responsive webpage is not appealing at all

  • I am reaching out to seek assistance with regards to building a hero section for my website similar to https://www.codium.ai. However, I have encountered difficulties in achieving the desired layout. Specifically, I am facing issues with aligning the text on the left side and having a video as the background on the right side. In the mobile view, the overall appearance is not satisfactory, as the video (set as a cover page with dimensions 1920×800) gets cropped. I have also attempted replacing the video with an image, but it did not yield different results.

    I would greatly appreciate it if you could provide a solution to this problem. I am aiming to set the same video as the cover page for both web and mobile views, while maintaining a consistent and appealing look across all devices. It is worth noting that the mobile view of “codium.ai” differs from the web view, yet both are visually appealing.

    To provide you with more context, please visit my website at https://www.bas6.shop and navigate to the second section, which is distinct from the mobile view of “codium.ai.” Upon inspecting the elements, I noticed that “codium.ai” has implemented a different video for the mobile view. Could you please guide me on how to incorporate a different video for mobile and web views?

    Thank you for your attention to this matter. I am looking forward to your expert advice and guidance

  • Hi there,

    to add different videos for different devices you need to:

    1. Edit your video HTML to include the hide-on-mobile class.
    So this line:

    <video loop muted autoplay poster="URL/TO/poster.jpg" class="background-video">

    becomes:

    <video loop muted autoplay poster="URL/TO/poster.jpg" class="background-video hide-on-mobile">

    2. then duplicate the video HTML block
    2.1 change the HTML classes of the duplicate to include hide-on-desktop hide-on-tablet ie.

    <video loop muted autoplay poster="URL/TO/poster.jpg" class="background-video hide-on-desktop hide-on-tablet">

    2.2 and update the videos URL for your mobile version

  • Thanks David,It is working.

    1. I have another query regarding that solution you have provided ,for example I want to write something on that video. Earlier I have had only one option to write it on a cover page video (by converting that video to set as cover page) But now after inserting two Custom HTML fileds the option to convert it as background video/cover page is not possible.
    so how can I make it a background video/coverpage and write something on it and how to align the text properly for desktop as well as for mobile ?

    2. I have noticed a particular issue concerning the cover page of the website. Specifically, when I place text or buttons on the cover page and subsequently refresh the page, the text becomes visible before the background video loads, resulting in a negative impact on the overall aesthetic and user experience of the website.

    Is there any way both should load at the same time ?

  • 1. This article should be insightful regarding this: https://docs.generatepress.com/article/adding-a-background-video/

    Can you try this structure, implementing David’s suggestion as well?

    2. It’s possible but this will need custom Javascript. This will likely affect your site’s performance though.

    To do this, you can give an anchor ID to your Container Block holding the text. Give it an ID of video-container.

    Then, with a video with class background-video, the JS would be something like this most likely:

    
    <script>
    const video = document.getElementById('background-video');
    const videoContainer = document.getElementById('video-container');
    
    video.addEventListener('loadeddata', function() {
      videoContainer.style.display = 'block'; // Display the video container once the video loads
    });
    </script>
    

    This JS can be added through a Hook Element hooked to wp_footer.

    Ideally, what this code does is check if the video is loaded, and then set the display of the Container.

    You’ll need to add a CSS like this as well:

    #video-container {
      display: none; /* Initially hide the video container for the text */
    }

    But again, to reiterate, adding JS for this can be detrimental to your performance – by how much? – that depends on how fast your site loads the script.

  • Thanks Fernando
    I followed all the instructions and achieved desired result. Is there any way I can change the text style for mobile and tablet devices other than Desktop view ?

  • If you use the GB Headline Block to add your text.
    Then whilst in the editor, you can switch to Tablet or Mobile previews and update its Typography styles for that screen size

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.