Jump to content

CSS to make image block change from 'inline' to 'stack' for mobile only

Go to solution Solved by tuanphan,

Recommended Posts

Hello,

For my Work page I am using 'inline' image blocks with a hover caption. I was hoping to find a way for the image block to switch to 'stack' for mobile only.  This way the work title can be displayed underneath, as hover isn't great for mobile. 

I have tried finding for a way to do this using CSS code, however no luck so far. I imagine it would be possible though.

Thank you
Georgia

Desktop-Inline_ImageBlock.png

Desired-Mobile-Stack-ImageBlock.png

Stack-ImageBlock_MobileOnly.png

Link to comment
  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

Add to Design > Custom CSS

@media screen and (max-width:767px) {
figcaption.image-caption-wrapper {
    opacity: 1 !important;
    visibility: visible !important;
    position: relative !important;
    overflow: hidden !important;
    padding: 0 !important;
}
h2 {
    margin-top: 0 !important;
}
}

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

Thank you, that's great.

However, is there a way to make it so only the project name is visible. I would like the secondary line that is on some of the projects (eg. 'Building a more playful world for developers, one macroblock at a time') to not be visible for mobile –as it appears odd that only some projects have them when they are all the same size.

This is why I thought having it switch to a 'Stack' image block might be a potential approach, as this way I can have it formatted to only be the image title for each project. However, I do understand if this is not the best way to go about it.

Thank you.

Using-provided-code.png

Using-Stack-ImageBlock.png

Link to comment
  • Solution

Use this new code

@media screen and (max-width:767px) {
figcaption.image-caption-wrapper {
    opacity: 1 !important;
    visibility: visible !important;
    position: relative !important;
    overflow: hidden !important;
    padding: 0 !important;
}
figcaption.image-caption-wrapper h2 {
    display: none;
}
}

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment


×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.