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

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