Home > database >  Change position of li elements in a ul list without changing the position of first element
Change position of li elements in a ul list without changing the position of first element

Time:09-03

<ul>
    <li>Icon</li>
    <li>1</li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
</ul>

Given a list like above, is there a way to change the position of the numbered <li> tags to an absolute positioning without changing the position of the first <li> tag?

CodePudding user response:

li:not(:first-child){
  /* write your css here  */
}

CodePudding user response:

You can assign a class to the element(s) you want to move specifically.

For example: <li >1</li> Then use CSS to change its positioning.

Hope this helped solve your problem.

  • Related