#search-box {
  position: relative;
  width: 100%;
  height: 10rem;
}
#box {
  box-sizing: border-box;
  border: 1px solid rgb(0, 0, 0, 0.2);
  border-radius: 25px;
  width: 20rem;
  height: 2.8rem;
}
#mag-container {
  position: absolute;
  top: 1rem;
  left: 1.3rem;
}
#mag {
  opacity: 50%;
  width: 1rem;
}<div id="search-box">
  <input type="text" name="search" class="search-tool" id="box" />
  <span id="mag-container">
        <img
          src="https://res.cloudinary.com/permalik/image/upload/q_50/v1609564792/magnifying-glass.svg"
          alt="magnifying glass"
          class="search-tool"
          id="mag"
        />
      </span>
</div>I am trying to position an icon inside a form (while the form itself is centered.)
Using a background image, some form of flex, transform or bootstrap seems to produce the desired result... but I want to know if there is a way to pull this off with certain nesting and positioning (alone.)
I've checked (Put icon inside input element in a form -- https://teamtreehouse.com/community/how-do-i-put-icons-inside-of-input-fields -- How can I center an absolutely positioned element in a div? -- and more.)
The answers I have found didn't exactly solve my issue.
Though I can keep using a background image, I'm simply curious if this is achievable.
Thanks for your time and effort.
     <div id="search-box">
      <input type="text" name="search" class="search-tool" id="box" />
      <span id="mag-container">
        <img
          src="https://res.cloudinary.com/permalik/image/upload/q_50/v1609564792/magnifying-glass.svg"
          alt="magnifying glass"
          class="search-tool"
          id="mag"
        />
      </span>
    </div>
#search-box {
  position: relative;
  width: 100%;
  height: 10rem;
}
#box {
  box-sizing: border-box;
  border: 1px solid rgb(0, 0, 0, 0.2);
  border-radius: 25px;
  width: 20rem;
  height: 2.8rem;
}
#mag-container {
  position: absolute;
  top: 1rem;
  left: 1.3rem;
}
#mag {
  opacity: 50%;
  width: 1rem;
}
 
    