How to add a class when there’s no sidebar?

if you are using an actual page template (as selected in the dropdown panel in the admin area) then using is_page_template(‘file-name.php’) in the body_class function will do it.

then, the CSS would be body.class-name #content would apply to only that template area.