How to handle a background-size: cover image in Wordpress?
Designer new to wordpress here. I want to take the featured image on a post and make it a hero image for the post single page.
The way I would normally do this is to create a div, set width to 100%, height to whatever vh I want, and then set background to the image url in the CSS with background size set to cover.
So how I'm trying to do this in Wordpress is like this:
section class="hero" style="background: url('?php echo $hero_image['url'];? ');" xmlns="http://www.w3.org/1999/html"
But that comes out a little wonky because setting background with inline styles overrides all the CSS back to default element stuff. Any ideas on how to do this better? Preferably without any plugins, as I'm trying to learn how to do as much in code as possible. Though I do already have Advanced Custom Fields and Custom Post Type UI installed and I'm using those extensively.
Topic custom-background images css Wordpress
Category Web