Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Bootstrap hide element puts content on new line

I am using bootstrap to conditionally display content only on larger devices. It works, but there is an issue:

<a class="navbar-brand p-0" href="#"><img src="images/logo.png" alt=""><span class="d-none d-md-block">My strapline<span></a>

The problem – the span content now aligns under the logo, rather than next to it without the "d-none d-md-block" class attributes.

How do I get the span content to stay inline with the logo?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Thank you

>Solution :

You can add the class "d-inline-block" to the span element to make it an inline-block level element and keep the span content inline with the logo.

<a class="navbar-brand p-0" href="#">
  <img src="images/logo.png" alt="">
  <span class="d-none d-md-inline-block">My strapline<span>
</a>

This will keep the span content inline with the logo on devices with medium or larger screen sizes (viewports width >= 768px), and hide the span content on smaller devices with viewports width < 768px.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading