Home  >  Q&A  >  body text

Button click in my React demo is unresponsive

<p>Why is there no response after clicking the button? </p> <p>My sample code: https://codesandbox.io/s/gallant-knuth-kwf55c</p> <p>I checked my code and found no problem. Please help me solve it. </p>
P粉899950720P粉899950720454 days ago644

reply all(1)I'll reply

  • P粉957723124

    P粉9577231242023-08-15 00:39:58

    The reason is that since all elements are set using position:absolute, the content div overlaps the header.

    This results in the header being hidden when interacting. So when we click, the click event is actually fired on the content, not the button (see below).

    We can take the following methods:

    • Either remove position:absolute
    • from the DIV
    • Using CSS Viewport Units / calc Functions calculate the height of content to avoid overlapping with the footer

    reply
    0
  • Cancelreply