Jump to content

How do i vertically center or align text within a transparent white overlay on mobile device?

Go to solution Solved by BradleyK,

Recommended Posts

How do i vertically center or align text within a transparent white overlay in landscape view on mobile device?

This is the code I'm currently using for a 1/3 transparent white overlay with black text overlay.

The code with "padding: 10px 70px !important;" forces the text to two lines of copy in vertical display mode on a mobile device.

However, when I rotate the view of the mobile device to landscape view, the single line of text aligns 10px from the bottom of the transparent white overlay. I would like the single line of copy to be centered vertically within the transparent white overlay. See attached examples of what it is currently displaying, and an example of what I would like to achieve.

/*Mobile Portfolio 1/3 Overlay*/
@media screen and (max-width: 1000px) {
.portfolio-grid-overlay .grid-item .portfolio-text {
        opacity:1 !important
}
.portfolio-overlay {
	height: 30% !important;
	top: unset !important;
	bottom: 0 !important;
	opacity: .7 !important;
}
.portfolio-text {
	justify-content: flex-end !important;
  	padding: 10px 70px !important;
    }
}

Thank you.

Mobile_Example_1000.jpg

Mobile_Example_1000_2.jpg

Link to comment
  • Replies 2
  • Views 1.2k
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

I just solved a case yesterday, I used this code

@media screen and (max-width:767px) {
.portfolio-text {
    justify-content: flex-end !important;
    top: unset !important;
    background-color: rgba(255,255,255,0.5) !important;
}
.portfolio-overlay {
    opacity: 0 !important;
}
}

If it doesn't work for your case, you can share page url, we can check it again easier

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
  • Solution

Hi Tuanphan,

I solved it with this code, although the text appears in the center of the portfolio grid item.

@media screen and (max-width: 1000px) {
.portfolio-grid-overlay .grid-item .portfolio-text {
        opacity:1 !important
}
.portfolio-overlay {
	height: 30% !important;
	margin: auto !important;
	bottom: 0 !important;
	opacity: .65 !important;
}
.portfolio-text {
	margin: auto !important;
    }
}

This is not a hover effect, but is an acceptable solution to confining the transparent white overlay to 1/3 of the portfolio grid height.

Thanks for your help.

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.