Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

d-block class moves the picture element

I want to hide a picture o a mobile device, to do that I'm using Bootstrap "d-block" class and add it into the picture, unfortunately it moves the picture to the left side, it doesn't matter if I want to hide it on a large or small screen (e.g. .d-none .d-lg-block .d-xl-none).

          <header>
      <div class="jumbotron jumbotron-fluid">
  <div class="container text-center">
    <div class="row">
      <div class="col-lg-12">
    <h1 class="display-4">Lorem ipsum</h1>
    <p class="lead text-uppercase">Lorem ipsum</p>
    <img width="25%;" class="fluid rounded-circle border d-none d-lg-block" src="Images/image.jpg"  alt="City"/>

  </div>
  </div>
  </div>
</div>
    </header>
          ```

1 Answer

Adding margin-right: auto; and margin-left: auto; will solve your problem!

In bootstrap, this will be the class mx-auto

<img width="25%;" class="fluid rounded-circle border d-none d-lg-block mx-auto" src="test.jpg"  alt="City"/>

How could I missed that?! Thank you Zhen for a great help ;) It works perfectly.