in English

मोडल हें नांव

लायटबॉक्स, वापरपी अधिसुचोवण्यो, वा पुरायपणान सानुकूल सामुग्री खातीर तुमच्या साइटचेर संवाद जोडपाक Bootstrap चें JavaScript मोडल प्लगइन वापरात.

कशें काम करता

Bootstrap च्या मोडल घटकाक सुरवात करचे पयलीं, आमचे मेनू पर्याय हालीं बदलल्यात म्हणून सकयल दिल्लें वाचपाची खात्री करात.

  • मोडल एचटीएमएल, सीएसएस, आनी जावास्क्रिप्ट हांणी तयार केल्ले आसात. ते दस्तावेजांतल्या हेर सगळ्या गजालींचेर स्थापन केल्यात आनी तातूंतल्यान स्क्रोल काडून उडयतात <body>जेणे करून मोडल सामुग्री ताचे बदला स्क्रोल करता.
  • मोडल “पार्श्वभूंय” चेर क्लिक केल्यार मोडल आपोआप बंद जातलें.
  • बूटस्ट्रॅप एका वेळार फकत एक मोडल विंडो समर्थन करता. नेस्टेड मोडलांक तेंको दिवंक ना कारण आमी मानतात की ते वापरप्याचे वायट अणभव आसात.
  • Modals use position: fixed, जें केन्ना केन्नाय ताच्या रेंडरींग विशीं मात्शें विशिश्ट आसूं येता. शक्य आसल्यार, हेर घटकां कडल्यान संभाव्य हस्तक्षेप टाळपा खातीर तुमचो मोडल HTML वयल्या पांवड्यावेल्या सुवातेर दवरात. तुमकां .modalदुसर् या थारावीक घटका भितर एक नेस्ट करतना समस्या येवपाची शक्यताय आसा.
  • परत एक फावट, कारण position: fixed, मोबायल डिव्हायसांचेर मोडल वापरपा कडेन कांय सावधानताय आसात. तपशीलां खातीर आमचे ब्राउझर आदार डॉक्स पळयात.
  • HTML5 आपली अर्थशास्त्र कशी व्याख्या करता ताका लागून, HTML autofocusगुणधर्माचो बूटस्ट्रॅप मोडलांत कसलोच परिणाम जायना. तोच परिणाम मेळोवपाखातीर, कांय सानुकूल जावास्क्रिप्ट वापरात:
$('#myModal').on('shown.bs.modal', function () {
  $('#myInput').trigger('focus')
})
ह्या घटकाचो एनिमेशन परिणाम prefers-reduced-motionमाध्यम क्वेरीचेर आदारून आसता. आमच्या सुलभताय दस्तावेजीकरणाचो उणो केल्ली गती विभाग पळयात .

डेमो आनी वापर मार्गदर्शक तत्वां खातीर वाचत रावचें.

उदाहरणां

सकयल एक स्थिर मोडल उदाहरण आसा (म्हळ्यार ताचें positionआनी displayअधिलिखित केल्यात). मोडल हेडर, मोडल बॉडी ( खातीर गरज आसा padding), आनी मोडल फूटर (पर्यायी) समाविष्ट आसात. शक्य आसल्यार तुमी डिसमिस कृती सयत मोडल हेडरांचो आस्पाव करचो, वा दुसरी स्पश्ट डिसमिस कृती दिवची अशें आमी मागतात.

<div class="modal" tabindex="-1">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">Modal title</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <p>Modal body text goes here.</p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

लायव्ह डेमो

सकयल दिल्लें बटण क्लिक करून काम करपी मोडल डेमो टॉगल करात. तो सकयल सरकतलो आनी पानाच्या वयल्या भागांतल्यान भितर फीको जातलो.

<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
  Launch demo modal
</button>

<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

स्थिर पार्श्वभूंय

जेन्ना पार्श्वभूंय स्थिराचेर सेट केल्ली आसता, तेन्ना ताचे भायर क्लिक करतना मोडल बंद जावचो ना. तो वापरून पळोवपा खातीर सकयल दिल्ल्या बटणाचेर क्लिक करात.

<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#staticBackdrop">
  Launch static backdrop modal
</button>

<!-- Modal -->
<div class="modal fade" id="staticBackdrop" data-backdrop="static" data-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="staticBackdropLabel">Modal title</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Understood</button>
      </div>
    </div>
  </div>
</div>

लांब सामुग्री स्क्रोल करप

जेन्ना वापरप्याच्या व्ह्यूपोर्ट वा डिव्हायसा खातीर मोडल चड लांब जातात, तेन्ना ते पानाचेरच स्वतंत्रपणान स्क्रोल करतात. आमी कितें म्हणपाक सोदतात तें पळोवपा खातीर सकयल दिल्लो डेमो वापरून पळयात.

तुमी स्क्रोल करपाक येवपी मोडलय तयार करूंक शकतात जो मोडल बॉडी स्क्रोल करपाक परवानगी .modal-dialog-scrollableदिता .modal-dialog.

<!-- Scrollable modal -->
<div class="modal-dialog modal-dialog-scrollable">
  ...
</div>

उबें केंद्रीत केल्लें

मोडल उबें केंद्र .modal-dialog-centeredकरपाक to जोडात ..modal-dialog

<!-- Vertically centered modal -->
<div class="modal-dialog modal-dialog-centered">
  ...
</div>

<!-- Vertically centered scrollable modal -->
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable">
  ...
</div>

टूलटिप्स आनी पोपोव्हर्स

गरज पडल्यार टूलटिप्स आनी पोपोव्हर मोडलां भितर दवरूं येतात. जेन्ना मोडल बंद जातात, तेन्ना भितरले खंयचेय टूलटिप्स आनी पॉपओव्हरय आपोआप काडून उडयतात.

<div class="modal-body">
  <h5>Popover in a modal</h5>
  <p>This <a href="#" role="button" class="btn btn-secondary popover-test" title="Popover title" data-content="Popover body content is set in this attribute.">button</a> triggers a popover on click.</p>
  <hr>
  <h5>Tooltips in a modal</h5>
  <p><a href="#" class="tooltip-test" title="Tooltip">This link</a> and <a href="#" class="tooltip-test" title="Tooltip">that link</a> have tooltips on hover.</p>
</div>

जाळी वापरप

.container-fluidभितर नेस्ट करून मोडला भितर बूटस्ट्रॅप ग्रिड प्रणालीचो वापर करचो .modal-body. मागीर, तुमी हेर खंयच्याय सुवातेर करतले तशें सामान्य ग्रिड प्रणाली वर्ग वापरात.

<div class="modal-body">
  <div class="container-fluid">
    <div class="row">
      <div class="col-md-4">.col-md-4</div>
      <div class="col-md-4 ml-auto">.col-md-4 .ml-auto</div>
    </div>
    <div class="row">
      <div class="col-md-3 ml-auto">.col-md-3 .ml-auto</div>
      <div class="col-md-2 ml-auto">.col-md-2 .ml-auto</div>
    </div>
    <div class="row">
      <div class="col-md-6 ml-auto">.col-md-6 .ml-auto</div>
    </div>
    <div class="row">
      <div class="col-sm-9">
        Level 1: .col-sm-9
        <div class="row">
          <div class="col-8 col-sm-6">
            Level 2: .col-8 .col-sm-6
          </div>
          <div class="col-4 col-sm-6">
            Level 2: .col-4 .col-sm-6
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

बदलपी मोडल आशय

बटणांचो एक गट आसा जो सगळे मात्शे वेगळ्या आशयांनी एकूच मोडल ट्रिगर करतात? खंयचें बटण क्लिक केलां ताचेर आदारून मोडलाची आशय बदलपाक वापरात event.relatedTargetआनी HTML data-*गुणधर्म ( कदाचित jQuery वरवीं ).

सकयल लायव्ह डेमो आसा आनी ताचे उपरांत उदाहरण HTML आनी JavaScript आसा. चड म्हायती खातीर, हाचेर तपशीलां खातीर मोडल इव्हेंट डॉक्स वाचातrelatedTarget .

<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" data-whatever="@mdo">Open modal for @mdo</button>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" data-whatever="@fat">Open modal for @fat</button>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal" data-whatever="@getbootstrap">Open modal for @getbootstrap</button>

<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="exampleModalLabel">New message</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <form>
          <div class="form-group">
            <label for="recipient-name" class="col-form-label">Recipient:</label>
            <input type="text" class="form-control" id="recipient-name">
          </div>
          <div class="form-group">
            <label for="message-text" class="col-form-label">Message:</label>
            <textarea class="form-control" id="message-text"></textarea>
          </div>
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Send message</button>
      </div>
    </div>
  </div>
</div>
$('#exampleModal').on('show.bs.modal', function (event) {
  var button = $(event.relatedTarget) // Button that triggered the modal
  var recipient = button.data('whatever') // Extract info from data-* attributes
  // If necessary, you could initiate an AJAX request here (and then do the updating in a callback).
  // Update the modal's content. We'll use jQuery here, but you could use a data binding library or other methods instead.
  var modal = $(this)
  modal.find('.modal-title').text('New message to ' + recipient)
  modal.find('.modal-body input').val(recipient)
})

एनिमेशन बदलात

मोडल फेड-इन एनिमेशन करचे पयलीं चडांत चड रुपांतर स्थिती थारायता, मोडल फेड-इन एनिमेशनाच्या निमाणें $modal-fade-transformचडांत चड रुपांतर थारायता ..modal-dialog$modal-show-transform.modal-dialog

तुमकां देखीक झूम-इन एनिमेशन जाय जाल्यार, तुमी सेट करूंक शकतात $modal-fade-transform: scale(.8).

एनिमेशन काडून उडोवप

पळोवपाक फिकट जावचे परस फकत दिसपी मोडलां खातीर, .fadeतुमच्या मोडल मार्कअपांतल्यान वर्ग काडून उडोवचो.

<div class="modal" tabindex="-1" aria-labelledby="..." aria-hidden="true">
  ...
</div>

गतिशील उंचाय

मोडाल उक्तो आसतना ताची उंचाय बदलल्यार, $('#myModal').modal('handleUpdate')स्क्रोलबार दिसल्यार मोडालाची सुवात परतून समायोजीत करपाक तुमी कॉल करचो.

सुलभताय

aria-labelledby="..."मोडल शीर्षकाचो संदर्भ दिवन, जोडपाची खात्री करात .modal. ते भायर, तुमी तुमच्या मोडल संवादाचें वर्णन aria-describedbyon कडेन दिवंक शकतात .modal. role="dialog"लक्षांत दवरात की आमी पयलींच जावास्क्रिप्ट वरवीं जोडटात म्हणून तुमकां जोडपाची गरज ना .

युट्युब व्हिडियो एम्बेड करप

YouTube व्हिडियो मोडलांत एम्बेड करपाक आपोआप प्लेबॅक थांबवपाक Bootstrap त नाशिल्ली अतिरिक्त JavaScript जाय आनी हेर. चड म्हायती खातीर हें उपकाराचें स्टॅक ओव्हरफ्लो पोस्ट पळयात .

पर्यायी आकार आसात

मोडलांचे तीन पर्यायी आकार आसतात, जे एक चेर दवरपाक संशोधक वर्गां वरवीं उपलब्ध आसात .modal-dialog. अरुंद दृश्यपोर्टांचेर आडवे स्क्रोलबार टाळपाखातीर हे आकार कांय ब्रेकपॉइंटांचेर किक इन करतात.

आकार वर्ग मोडल चडांत चड-रुंदी
ल्हान .modal-sm 300px
डिफॉल्ट कांयच ना 500px
व्हड .modal-lg 800px
अतिरिक्त व्हडलें .modal-xl 1140px

संशोधक वर्ग नाशिल्लो आमचो मुलभूत मोडल “मध्यम” आकाराचो मोडल घडयता.

<div class="modal-dialog modal-xl">...</div>
<div class="modal-dialog modal-lg">...</div>
<div class="modal-dialog modal-sm">...</div>

वापर

मोडल प्लगइन मागणी प्रमाणें, डेटा गुणधर्म वा जावास्क्रिप्ट वरवीं तुमची लिपिल्ली सामुग्री टॉगल करता. तशेंच तो मुलभूत स्क्रोलिंग वर्तनाचेर अधिलिखित .modal-openकरपाक जोडटा आनी मोडला भायर क्लिक करतना दाखयल्ले मोडल काडून उडोवपाखातीर क्लिक क्षेत्र पुरवण करपाक a तयार करता.<body>.modal-backdrop

डेटा गुणधर्मां वरवीं

जावास्क्रिप्ट बरयनासतना मोडल सक्रिय करात. data-toggle="modal"बटणा सारकिल्या नियंत्रक घटकाचेर सेट करात , एक वा टॉगल करपाक विशिश्ट मोडलाक लक्ष्य करपाक data-target="#foo"वा वांगडा सेट करात.href="#foo"

<button type="button" data-toggle="modal" data-target="#myModal">Launch modal</button>

जावास्क्रिप्ट वरवीं

myModalजावास्क्रिप्टाच्या एकाच ओळीन id आशिल्ल्या मोडलाक कॉल करात :

$('#myModal').modal(options)

पर्याय आसात

पर्याय डेटा गुणधर्म वा जावास्क्रिप्ट वरवीं पास करूंक शकतात. डेटा गुणधर्मांखातीर, पर्याय नांव जोडात data-, जशें data-backdrop="".

नांव प्रकार डिफॉल्ट वर्णन
फाटभूंयेर आसता बूलियन वा स्ट्रिंग'static' खरें एक मोडल-पार्श्वभूंय घटक समाविष्ट करता. पर्यायीपणान, staticक्लिकाचेर मोडल बंद करिनाशिल्ली फाटभूंय निर्देशीत करात.
कीबोर्ड वापरतात बूलियन हें नांव खरें एस्केप की दामल्यार मोडल बंद करता
केंद्रीत बूलियन हें नांव खरें आरंभ करतना मोडलाचेर लक्ष केंद्रीत करता.
दाखोवचें बूलियन हें नांव खरें आरंभ करतना मोडल दाखयता.

पद्दती

अतुल्यकालिक पद्दती आनी संक्रमण

सगळ्यो एपीआय पद्दती अतुल्यकालिक आसतात आनी संक्रमण सुरू करतात . संक्रमण सुरू जातकच पूण सोंपचे पयलीं ते फोन करप्या कडेन परततात . ते भायर, संक्रमण घटकाचेर एक पद्दत कॉल दुर्लक्षीत जातलें .

चड म्हायती खातीर आमचें जावास्क्रिप्ट दस्तावेज पळयात .

.modal(options)

तुमची सामग्री मोडल म्हणून सक्रिय करता. एक पर्यायी पर्याय स्वीकारता object.

$('#myModal').modal({
  keyboard: false
})

.modal('toggle')

हाताळणीन एक मोडल टॉगल करता. मोडल प्रत्यक्षांत दाखोवचे पयलीं वा लिपोवचे पयलीं (म्हळ्यार shown.bs.modalवा hidden.bs.modalघडणूक घडचे पयलीं) कॉलराक परतता.

$('#myModal').modal('toggle')

.modal('show')

हाताळणीन एक मोडल उगडटा. मोडल प्रत्यक्षांत दाखोवचे पयलीं (म्हळ्यार shown.bs.modalघडणूक घडचे पयलीं) कॉलराक परतता.

$('#myModal').modal('show')

.modal('hide')

हाताळणीन एक मोडल लिपयता. मोडल प्रत्यक्षांत लिपचे पयलीं (म्हळ्यार hidden.bs.modalघडणूक घडचे पयलीं) कॉलराक परतता.

$('#myModal').modal('hide')

.modal('handleUpdate')

मोडाल उक्तो आसतना ताची उंचाय बदलल्यार (म्हळ्यार स्क्रोलबार दिसल्यार) मोडलाची सुवात हाताळणीन परतून समायोजीत करात.

$('#myModal').modal('handleUpdate')

.modal('dispose')

एका घटकाचें मोडल नश्ट करता.

घडणुको

बूटस्ट्रॅपाचो मोडल वर्ग मोडल कार्यक्षमतायांत हुक करपाखातीर कांय घडणुको उक्ती करता. सगळ्यो मोडल घडणुको मोडलाचेरच (म्हळ्यार <div class="modal">) फायर करतात.

इव्हेंट प्रकार Description
show.bs.modal This event fires immediately when the show instance method is called. If caused by a click, the clicked element is available as the relatedTarget property of the event.
shown.bs.modal This event is fired when the modal has been made visible to the user (will wait for CSS transitions to complete). If caused by a click, the clicked element is available as the relatedTarget property of the event.
hide.bs.modal This event is fired immediately when the hide instance method has been called.
hidden.bs.modal This event is fired when the modal has finished being hidden from the user (will wait for CSS transitions to complete).
hidePrevented.bs.modal मोडल दाखयल्ल्या वेळार ही घडणूक फायर जाता, ताची फाटभूंय आसता staticआनी मोडाला भायर क्लिक वा एस्केप की दामप कीबोर्ड पर्यायान वा data-keyboardसेट केला तेन्ना फायर जाता false.
$('#myModal').on('hidden.bs.modal', function (event) {
  // do something...
})