Bootstrap 4: How to include a background image without CSS

Bootstrap defines CSS classes to cover most common website design elements, but I can't figure out how to specify a background image file using Bootstrap classes without adding clunky customized CSS.

1 Answer

You will have to give background-image:url(''); property using style to give the path of the image and you can make the image responsive using .bg-image class.
Here's how you can do that:
Add background-image via inline CSS.
Add .bg-image class to scale the image properly and to enable responsiveness.
Example:

<div>
</div>

vh stands for viewport height.
Here the height:100vh means 100% of the available height.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like