[Support request] Change background image – to normal html

Home Forums Support [Support request] Change background image – to normal html

Home Forums Support Change background image – to normal html

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1005728
    Anders Nielsen

    Can you change the image (the two images side by side) so that they are not called via CSS – but via html, so that lazyload works correctly on the image…

    But keep the design?

    #1006090
    David
    Staff
    Customer Support

    Hi there,

    is that content being generated by a plugin?

    #1006131
    Anders Nielsen

    No, just html/css..

    Now I have changed the left image to “normal” html, and the right is loaded from CSS.

    I wan’t the left image, to behave like the right one.. ( when scaling up and down – responsive)

    But I can’t figure out the css

    #1006262
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Both seem to be using background images still.

    Basically, you want a container with the image and text inside of it:

    <div class="image-container">
        <img src="URL TO IMAGE" />
        <span class="image-text">Your text here</span>
    </div>

    If you can set that structure up, we can help with the necessary CSS.

    Let me know πŸ™‚

    #1007092
    Anders Nielsen

    Awesome πŸ™‚

    I have set it up… πŸ™‚

    #1007182
    Tom
    Lead Developer
    Lead Developer

    Give this CSS a shot:

    .image-container {
        position: relative;
    }
    
    .image-container .image-text {
        position: absolute;
        left: 0;
        bottom: 10%;
        background: #222;
        color: #fff;
        padding: 10px;
    }
    #1007973
    Anders Nielsen

    Thx.

    The headline works fine, but the image does not resize on mobile / tablet.

    Thats the tricky part πŸ™‚

    #1008266
    Tom
    Lead Developer
    Lead Developer

    The image looks good to me as I size down the page. Is there a specific width I should be looking at?

    #1008639
    Anders Nielsen

    The right one changes image height on mobile, and also has a minimum height to it when scaling down

    #1008818
    Tom
    Lead Developer
    Lead Developer

    That’s because the right one is still a background image. Background images behave differently to static images (which the left column is now). Are you wanting the static image to behave like the background image?

    #1008828
    Anders Nielsen

    Are you wanting the static image to behave like the background image?

    Yes, that was the idea – so the lazyload works.

    #1008969
    Tom
    Lead Developer
    Lead Developer

    You could try this:

    .image-container img {
        object-fit: cover;
        height: 100%;
    }
    
    .image-container {
        position: relative;
        height: 180px;
        overflow: hidden;
        min-height: 180px;
    }
Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.