- This topic has 11 replies, 3 voices, and was last updated 3 years, 3 months ago by Leo.
-
AuthorPosts
-
January 13, 2021 at 7:01 am #1617206William
Hi there,
I use the featured image of posts as the background for the header element.
It looks great for images such as this. But, for others such as this, the text can be a little difficult to read, due to the image in the background. This applies for both desktop and mobile.
I currently apply a box-shadow over the image to darken it to make it easier to read, inside the header element. Is it possible to have the box-shadow become gradually darker, starting at the point of either when the title is, or where the description/excerpt starts, for both desktop and mobile?
January 13, 2021 at 8:02 am #1617296DavidStaffCustomer SupportHi there,
tricky to add the shadow and keep it responsive, especially if the hero content size varies from post to post.
How about adding a little text shadow to the hero content:
.page-hero { text-shadow: 2px 2px 2px rgba(0,0,0,0.75); }
In the property above the 3rd: 2px is the blue radius. At 2px it adds a hard fill behind the text, but you can also set it to much higher value eg. 16px to have more subtle background.
Let me know.
January 13, 2021 at 8:57 am #1617388WilliamAh gotcha – I think that just about works for me. Thank you for that help.
Is there anyway to make the box-shadow a gradient anyway? Just so I can compare and contrast what you provided above with that?
January 13, 2021 at 2:27 pm #1617718LeoStaffCustomer SupportA post like this might help:
https://stackoverflow.com/questions/9649706/css3-box-shadow-linear-gradientJanuary 15, 2021 at 5:53 pm #1620725WilliamThat’s really helpful thanks! With this, I want something like I’ve done in yellow:
The only issue is that I don’t know how to create such CSS to work on the image overlay shadow for just that page hero?
January 16, 2021 at 11:11 am #1621593LeoStaffCustomer SupportNot sure if I fully understand the question.
So basically you want to apply that effect to a specific page hero only?
If so add a custom class like
special-gradient
:
https://docs.generatepress.com/article/header-element-overview/#element-classesThen the CSS would be:
.page-hero.special-gradient { CSS here }
January 16, 2021 at 1:17 pm #1621715WilliamThat makes sense thank you. I can create such a class that:
.special-gradient { background-image: linear-gradient(0deg, rgba(20,20,20,0.7),rgba(20,20,20,0.1)); }
But how would I make sure the featured image is the background, with the overlay shadow of above ontop of it, in CSS?
January 16, 2021 at 4:27 pm #1621827LeoStaffCustomer SupportHmm I’m not sure if this method will work for featured images unfortunately.
Can you try replacing
background-image
withbackground
?January 16, 2021 at 4:42 pm #1621836WilliamJust changed and does not seem to have made a difference.
Is this a limitation or is it possible to have a linear gradient overlay ontop of featured images in the hero element?January 16, 2021 at 4:43 pm #1621840LeoStaffCustomer SupportJanuary 16, 2021 at 6:19 pm #1621887WilliamThat’s it, perfect. Thank you so much, huge help!
January 16, 2021 at 6:25 pm #1621890LeoStaffCustomer SupportNo problem 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.