简体   繁体   English

如何在 HTML/CSS 中使用语义 UI 创建模态?

[英]How can I create a modal using Semantic UI in HTML/CSS?

So I'm creating a GUI using html and want to open a modal on the click of a button.所以我正在使用 html 创建一个 GUI,并希望通过单击按钮打开一个模式。 What JS would I need to make this happen?我需要什么 JS 才能做到这一点? Below is the code with a basic modal all I need is the JS to make it open.下面是带有基本模式的代码,我只需要 JS 即可打开它。 I'm using nodejs and electron.我正在使用 nodejs 和电子。

HTML HTML

    <div style = 'position: fixed; top: 25px; left: 900px ' class = 'ui container'>
      <input type="button" id="sTask" class = 'ui inverted basic green button' value="Start Tasks">
      <input type="button" id="eTask" class = 'ui inverted basic yellow button' value="End Tasks">
      <input type="button" id="dTask" class = 'ui inverted basic red button' value="Delete Tasks">
    </div>

      <div style ="position:fixed; top: 25px; left: 102px">
        <button id="cTask" class = 'ui inverted basic blue button' data-modal-target="empty">Create New Task </button>

        <div id="modal" class="ui basic modal" data-model="empty">
          <div class="ui icon header">
            Archive Old Messages
          </div>
          <div class="content">
            <p>Your inbox is getting full, would you like us to enable automatic archiving of old messages?</p>
          </div>
          <div class="actions">
            <div class="ui red basic cancel inverted button">
              <i class="remove icon"></i>
                No
            </div>
          <div class="ui green ok inverted button">
              <i class="checkmark icon"></i>
                Yes
          </div>
        </div>
    </div>

You need to call the show method on the modal, to do it on button click you need to put it in a click event.您需要在模态上调用show方法,要在按钮单击时执行此操作,您需要将其放入单击事件中。

$('#modalbutton').on('click', () => {
  $('#modal')
    .modal('show');
})

Working JSFiddle工作JSFiddle

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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