Within my webpage, I have incorporated two bootstrap containers - one placed inside the header navbar and the other below it. Both containers contain text content. My goal is to shift the text within the navbar container 15px to the left for all responsive breakpoints.
I attempted to achieve this by applying a negative margin as shown in the code snippet below:
<nav class="navbar px-0 navbar-light fixed-top bg-primary">
<div class="container"><div style="margin-left: -15px;">Text1</div></div>
</nav>
<div class="container" style="margin-top: 50px;">Text 2</div>
You can view an example on JSFiddle.
While this approach does work, it does have a significant issue. As the browser width decreases, the text within the header navbar extends beyond the screen. Is there a way to prevent this from happening? It's clear that using @media
queries could solve the problem, but I believe there might be a better solution.