I am trying to put a pseudo :after element at 30 pixels to the right of the menu list item.
Regardless of the text length of the element, I want the element to be 30 pixels to the right.
I split the following code into the minimum minimum that I think is needed for this problem.
Please note that this is a mobile menu. Menu and a tag extends the width of the browser (phone).
#menu-main-menu-1 li { position: relative; list-style: none; } #menu-main-menu-1 li a { padding: 18px 0; display: block; text-align: center; } #menu-main-menu-1 a:after { content: "\25CF"; position: absolute; right: 0; left: 150px; top: 20px; }
<ul id="menu-main-menu-1"> <li class="menu-item"> <a href="#">Menu Item</a> </li> <li class="menu-item"> <a href="#">Long Menu Item Text</a> </li> </ul>
The above code gives the following result:

As you can see, I need to put it 150 pixels to the left to get the element, which should go 30 pixels to the right of the element. It works, but I can anticipate the problem, if the menu item has a lot of text, it will exceed 150 pixels and the element will be in the text. For instance:

I need the element to be 30px to the right of the text, regardless of length. So it will look like this:

Here is the JSFiddle link: JSFiddle
Please note that I deleted many unnecessary styles that do not affect the functionality of this issue (color, fonts, etc.).
Any help would be greatly appreciated!
thanks
source share