-
OliverS
Hi,
On each page I have a container which holds two text blocks. This container block is only visible for mobile devices (it is hidden on desktop and tablet). Each page has a hero image at the top.What I like to accomplish is the following:
The first text block should be placed on the left and middle of the hero image on mobile and the container, which holds the text block, should have occupy a max width of around 30 – 40% from the left of the image.
The second text block is the copyright of the image and should be placed just beneath the hero image on the right.(Actually it should look like more or less the same as on desktop)
I tried to do this with setting under spacing for container and / or text block. The problem is that, depending on the mobile device, the text block is never really in the middle of the visible hero image. But I’d want that it looks the same on every mobile device. So I guess I need to use also the flex option under layout, don’t I?
I tried this but I never got a satisfying solution. I find this very difficult with the flex layout.
Can you help me please.
Here is a screenshot of one page in chrome mobile version: https://postimg.cc/phSsPqNR
Please see also my private information.Thank you very much.
Oliver
-
Hey Oliver,
Using negative margins like this can certainly be tricky.
Is there a particular reason why the hero with the background image and the text are in completely separate locations? It would be a lot easier to achieve the layout you’re after if they were located inside of the same container.
-
OliverS
Hey Tom,
I had them in the same container. But after I talked to David we seperated the text for mobile version due to performance reasons. Here is the thread between David and me:
https://generate.support/topic/page-hero-hook-customize-text-and-merge-nav/page/2/#post-121451But if you’d recommend another approach achieving the same performance results than I am happy to follow.
Thanks a lot
Regards from Berlin
Oliver
-
Ah, got it. David is on vacation, so I’ll do my best to follow along with his thinking here.
Would it be possible for you to add the text in the box inside the same Container as the Image Block that you added on mobile only? Or would that mess with something?
-
OliverS
I do not think that it would mess w/ sth. But I am not very good with that. I just followed Davids advise e.g. put the additional css codes on places he mentioned.
The page hero is a hook element (named page hero) with dynamic text in it. This text is coming from a field (ACF).
So what I need to do is to address this text inside the container which holds the image for mobile only. But I do not know how to do it. I guess I need to change sth. with the hook element or / and change Davids css?
Thanks for tips.
Cheers Oliver
-
If it were me (and I may be missing context here, so I apologize if so), I would do the following:
1. Add my Container (you already have this)
2. Add my image inside of the Container (you already have this)
3. After the Image block, I would add a new Container
4. In this new Container, I would add my textIf we have that structure, we can use a little CSS to place the container with the text on top of the image quite easily.
-
OliverS
Ok, I did as you said. https://postimg.cc/pmFzzjBM
Now is missing the CSS for the post meta text and the text block which holds the copyright of the image.
Thank you for your afford.
Oliver
-
Ok, next steps.
1. Give the Container with the hero image inside of it a class name. Let’s say:
mobile-hero
2. Give the Container with the text inside of it a class name. Let’s say:mobile-hero-text
Add this CSS:
.mobile-hero { position: relative; } .mobile-hero > .mobile-hero-text { position: absolute; top: 50%; left: 50%; width: 200px; transform: translate(-50%, -50%); }
You can add things like a background color, text color etc.. in the block settings for that Container.
For the copyright, let’s do the same thing. Are you able to add it inside of our
mobile-hero
Container block, and give it a class name of it’s own? -
OliverS
Hi Tom,
thank you very much. This was awesome help. From here I can go alone.
Have a nice weekend.
All the best
Oliver
-
Glad I could help! You as well 🙂
Thanks!
- You must be logged in to reply to this topic.