Skip to content

Instantly share code, notes, and snippets.

@webzunft webzunft/css

Created Sep 17, 2018
Embed
What would you like to do?
Reserve ad space with a ratio
/** this code allows to reserve ad space with a ratio, e.g., when width is 100% and height needs to be adjusted dynamically
https://www.w3schools.com/howto/howto_css_aspect_ratio.asp
"top-banner-ads" is the class of the main container, in Advanced Ads derived from the placement name
**/
.top-banner-ads {
width: 100%;
height: auto;
padding-top: 12.4%; /* 728:90 ratio */
position: relative;
}
.top-banner-ads > div {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.