Site logo

[Resolved] Adding offset ‘borders’ to images

Home Forums Support [Resolved] Adding offset ‘borders’ to images

Home Forums Support Adding offset ‘borders’ to images

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1846682
    CRAIG

    Hi Folks,

    I am trying to add a couple of ‘offset’ borders to some of the images on my site to add some of my brand colours to the images.

    I have added a link (privately) to a website which has this effect on the last 2 main images on their homepage.

    I have tried to inspect the CSS but to be honest I’m not too sure what it means.

    Could you suggest a way that I could achieve a similar effect?

    I was going to upload the image into photoshop and try to add the effects that way, but I get the feeling there’s probably an easy way to do this within generate press leaving the original image untouched.

    Thanks in advance for any help you can provide.

    #1846725
    David
    Staff
    Customer Support

    Hi there,

    i converted that sites CSS to this:

    .image-borders img {
        position: relative;
    }
    
    .image-borders img:before {
        content: "";
        height: calc(100% + 5px);
        width: calc(100% + 5px);
        border: 4px solid #9191f8;
        position: absolute;
        z-index: 1;
        top: -15px;
        right: -15px;
    }
    
    .image-borders img:after {
        content: "";
        height: 100%;
        width: 100%;
        border: 2px solid #70f1b4;
        position: absolute;
        top: -25px;
        right: -25px;
    }

    With that added – give the Image Block an Additional CSS Class of: image-borders

    #1846807
    CRAIG

    Hi David,

    Thanks for taking the time to do this.

    I have added the CSS and given the image block the class as suggested via Advanced > Additional CSS class(es)

    So far it doesn’t seem to be displaying anything.

    I originally thought it might be that there weren’t any colours but I can see you’ve added the HEX codes from the reference site, and so I was expecting to see them show up

    Hmm…..

    #1846814
    Leo
    Staff
    Customer Support

    Is there a specific image we should be looking at?

    #1846860
    CRAIG

    The images are the 2 directly above the ‘latest posts’ section

    Both images have had the CSS class referred to above added

    #1846917
    Ying
    Staff
    Customer Support

    Hi Craig,

    Try to replace David’s CSS with this:

    .image-borders{
        position: relative;
    }
    .image-borders:before {
        content: "";
        height: calc(100% + 5px);
        width: calc(100% + 5px);
        border: 4px solid #9191f8;
        position: absolute;
        z-index: 1;
        top: -15px;
        right: -15px;
    }
    
    .image-borders:after {
        content: "";
        height: 100%;
        width: 100%;
        border: 2px solid #70f1b4;
        position: absolute;
        top: -25px;
        right: -25px;
    }
    .image-borders img {
        z-index: 2;
        position: relative;
    }

    Let me know if it works 🙂

    #1846924
    CRAIG

    This has worked well

    The only issue is that the borders are “on top” of the image

    Is there a way I can set them to be “behind” the image, so that the only parts of the border which show are those which are above and to the right of the image?

    #1846931
    Ying
    Staff
    Customer Support
    #1846935
    CRAIG

    This has worked perfectly! Thank you so much!

    #1846939
    Ying
    Staff
    Customer Support

    You are welcome 🙂

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