Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

HTML

Damian Szymanski
Damian Szymanski
11,843 Points

Question on how to put an image/icon next to an Input field - Bootstrap

Hello!

I am a little bit stuck. Im trying to put an icon next to my search field with bootstrap like this: https://imgur.com/a/aY00v3w . I am having trouble making it look like that image and it keeps doing this: https://imgur.com/a/u9PCMVn . Any Suggestions? (I have included the code below)

Thanks, Damian.

  <nav class="navbar navbar-expand-lg navbar-light">
    <div class="input-group mb-3">
      <input type="text" class="form-control text2 push-left" placeholder="Recipient's username" aria-label="Recipient's username" aria-describedby="button-addon2">
    </div>
      <img src="/search/img/ocean_usr.jpg" class="ml-2" height="40" width="40" id="oceanIcn">
    </nav>

3 Answers

Damian Szymanski
Damian Szymanski
11,843 Points

Thank you for all the responds! fixed it by putting the img tag into a div with a class="container" .

Justin Townsend
Justin Townsend
4,720 Points

Hey Damian, hmm I'm not sure if this will work but what if you took the img tag and put it inside the div tag, rather then putting it outside the div tag.

yes