-3

Hello everyone I was wondering how I get the ::after element from my <input> search field into the input field itself (https://i.stack.imgur.com/Gc1MU.png).

I've tried some things but at the end my result was to set the CSS style for the ::after element to margin-left: -25px;.

I am not sure if this is the best solution, especially because I am using a negative value for margin. Is there any better solution for this? Or is this the only way?

Ehsan
  • 12,655
  • 3
  • 25
  • 44
TheKeymaster
  • 857
  • 1
  • 11
  • 27
  • Use `position` for it. – LKG Aug 23 '17 at 13:50
  • [I can't get `::after` to work with an `` at all](https://stackoverflow.com/questions/2587669/can-i-use-the-after-pseudo-element-on-an-input-field). Perhaps you should include a [mcve] showing what you have so far. – Quentin Aug 23 '17 at 13:55

1 Answers1

0

You can set it using position:

.parentElement {
    position: relative;
}

.childElement {
    position: absolute;
    top: 5px;
    right: -25px;
}
Ehsan
  • 12,655
  • 3
  • 25
  • 44
Super User
  • 9,448
  • 3
  • 31
  • 47