Custom CSS can be difficult to maintain, so if possible, I'd recommend using a container with a conditional border. You can expand contents to fit the container & remove padding/margins
Otherwise, it looks like you could try something like this: