How to make the position of the element always in the same place?

  • 0
    Hello everyone ! Please tell me when you click on the picture (made a red border), the element is displayed, everything is fine, but when the screen is redrawn, this element flies away, how to fix it at one point (for example, under the picture)

    Thanks in advance!
    JavaScript Anonymous, Nov 22, 2020

  • 1 Answers
  • 0
    Position through absolute. Place the drop-down menu and the button calling this menu inside one block.

    You need to unify everything. You have a lot of code duplication.

    For each button that changes the text style, you can add a js-control class and add data-attributes

    data-property - the name of the property that will change and data-value - the value that will be substituted.

    Those. you find all the elements with the js-control class, hang one click handler on them, after the click, the property that must change (property = data-propety) and the value that must be changed (value = data-value) are defined and apply them [property] = value;
    Audrey Cervantes

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!