Archived topic
How to center content in hook element
3 replies · Started by ETO on October 11, 2021
Hello!
I added some Adsense ads using the elements' hook feature. The problem is that the one in generate_after_main_content is not aligned centre but is always on the left. However I tried, I could not display it in the centre.
Could you please have a look at it?
Hi there,
You can try with this CSS:
div#ad-slot {
margin-left: auto;
margin-right: auto;
min-width: 100% !important;
}
But keep in mind that this has limitations. This can't control what's inside an iframe, unfortunately.
@media screen and (max-width: 860px) {
#ad-slot {
min-height: 100px;
}
}
I have already used the code above. Should I add your code to this code or should I use your code separately?
@media screen and (max-width: 860px) {
#ad-slot {
min-height: 100px;
margin-left: auto;
margin-right: auto;
min-width: 100% !important;
}
}
Should it be like this?
Hi there,
you're CSS will only target smaller screens upto 860px wide. Whereas the image you linked to was for a large desktop screen. So you should add Elvins code as it was provided.