简体   繁体   中英

React Modal in reactjs

I have used react-modal for modal dialog,

and in my reactjs render(), i have the following modal

return(
        <ReactModal
        isOpen={this.state.showModal}
        contentLabel="Minimal Modal Example">
        <button style={styleClose} onClick={this.handleCloseModal}>
      CloseModal</button>
        {items}
     </ReactModal>
    )

But when this dialog open, the items behind are overlapping, how can I have only dialog being visible and not the background elements?

The elements that are overlapping are the components that have radiobuttons. Normal text are not overlapping. How can i make these buttons not to overlap?

I tried setting the zIndex and apply styling but that doesnt work.

Also how can i have close when i also click esc on keyboard ?

The first part of your question needs more info for clarification, I can answer the second part:

Add this to your modal element: shouldCloseOnEsc={true}

If you haven't, remember to also add onRequestClose={<your component method that hides the modal}

Check this link for more usage: http://reactcommunity.org/react-modal/#usage

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM