W3.CSS Modalı


Kalıcı, geçerli sayfanın üstünde görüntülenen bir iletişim kutusu/açılır penceredir:

×

Modal Header

Hello World!

Go back to W3.CSS Modal to learn more!

Modal Footer Close


W3.CSS Modal Sınıfları

W3.CSS, kalıcı pencereler için aşağıdaki sınıfları sağlar:

Sınıf tanımlar
w3-modlu kalıcı kapsayıcı
w3-modal-içerik kalıcı içerik

Modal Oluştur

w3-modal sınıfı, bir modal için bir kap tanımlar .

w3-modal-content sınıfı , kalıcı içeriği tanımlar.

Modal içerik herhangi bir HTML öğesi olabilir (div'ler, başlıklar, paragraflar, resimler vb.).

Örnek

<!-- Trigger/Open the Modal -->
<button onclick="document.getElementById('id01').style.display='block'"
class="w3-button">Open Modal</button>

<!-- The Modal -->
<div id="id01" class="w3-modal">
  <div class="w3-modal-content">
    <div class="w3-container">
      <span onclick="document.getElementById('id01').style.display='none'"
      class="w3-button w3-display-topright">&times;</span>
      <p>Some text in the Modal..</p>
      <p>Some text in the Modal..</p>
    </div>
  </div>
</div>


Bir Modal Aç

Modu açmak için herhangi bir HTML öğesini kullanın. Ancak bu genellikle bir düğme veya bağlantıdır.

onclick niteliğini ekleyin ve document.getElementById() yöntemini kullanarak kipin kimliğini ( örneğimizde id01 ) işaretleyin.


Bir Modalı Kapat

Bir kipi kapatmak için, kipin kimliğini ( id01 ) işaret eden bir onclick özniteliğiyle birlikte w3-button sınıfını bir öğeye ekleyin. Ayrıca kipin dışına tıklayarak da kapatabilirsiniz (aşağıdaki örneğe bakın).

İpucu: × yakın simgeler için "x" harfi yerine tercih edilen HTML varlığıdır.


Kalıcı Üstbilgi ve Altbilgi

Kalıcı içerik içinde farklı bölümler oluşturmak için w3-container sınıflarını kullanın :

×

Modal Header

Some text..

Some text..

Modal Footer

Örnek

<div id="id01" class="w3-modal">
  <div class="w3-modal-content">

    <header class="w3-container w3-teal">
      <span onclick="document.getElementById('id01').style.display='none'"
      class="w3-button w3-display-topright">&times;</span>
      <h2>Modal Header</h2>
    </header>

    <div class="w3-container">
      <p>Some text..</p>
      <p>Some text..</p>
    </div>

    <footer class="w3-container w3-teal">
      <p>Modal Footer</p>
    </footer>

  </div>
</div>

Kart Olarak Modal

Modu bir kart olarak görüntülemek için w3-modal-content kabına w3-card-* sınıflarından birini ekleyin :

×

Modal Header

Some text..

Some text..

Modal Footer

Örnek

<div class="w3-modal-content w3-card-4">

Hareketli Modeller

Modu belirli bir yönden kaydırmak için w3-animate-zoom|top|bottom|right|left sınıflarından herhangi birini kullanın :

×

Modal Header

Some text..

Some text..

Modal Footer

×

Modal Header

Some text..

Some text..

Modal Footer

×

Modal Header

Some text..

Some text..

Modal Footer

×

Modal Header

Some text..

Some text..

Modal Footer

×

Modal Header

Some text..

Some text..

Modal Footer

×

Modal Header

Some text..

Some text..

Modal Footer

×

Modal Header

Some text..

Some text..

Modal Footer

Örnek

<div class="w3-modal-content w3-animate-zoom">
<div class="w3-modal-content w3-animate-top">
<div class="w3-modal-content w3-animate-bottom">
<div class="w3-modal-content w3-animate-left">
<div class="w3-modal-content w3-animate-right">
<div class="w3-modal-content w3-animate-opacity">

Ayrıca w3-modal öğesinde w3-animate-opacity sınıfını ayarlayarak modun arka plan rengini soldurabilirsiniz:

Örnek

<div class="w3-modal w3-animate-opacity">

Modal Görüntü

Tam boyutta modal olarak görüntülemek için resmin üzerine tıklayın:

Norveç
×
Norway

Örnek

<img src="img_snowtops.jpg" onclick="document.getElementById('modal01').style.display='block'" class="w3-hover-opacity">

<div id="modal01" class="w3-modal w3-animate-zoom" onclick="this.style.display='none'">
  <img class="w3-modal-content" src="img_snowtops.jpg">
</div>

Modal Resim Galerisi

Tam boyutta görüntülemek için bir resmin üzerine tıklayın:

×

Örnek

<div class="w3-row-padding">
  <div class="w3-container w3-third">
    <img src="img_snowtops.jpg" style="width:100%" onclick="onClick(this)">
  </div>
  <div class="w3-container w3-third">
    <img src="img_lights.jpg" style="width:100%" onclick="onClick(this)">
  </div>
  <div class="w3-container w3-third">
    <img src="img_mountains.jpg" style="width:100%" onclick="onClick(this)">
  </div>
</div>

<div id="modal01" class="w3-modal" onclick="this.style.display='none'">
  <img class="w3-modal-content" id="img01" style="width:100%">
</div>

<script>
function onClick(element) {
  document.getElementById("img01").src = element.src;
  document.getElementById("modal01").style.display = "block";
}
</script>

Kalıcı Giriş Formu

Bu örnek, oturum açmak için bir mod oluşturur:


× Avatar
Remember me
Forgot password?

Örnek


Sekmeli İçerikli Modal

Bu örnek, sekmeli içeriğe sahip bir modal oluşturur:

×

Header

London

London is the most populous city in the United Kingdom, with a metropolitan area of over 9 million inhabitants.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Örnek


Close the Modal

In the examples above, we use a button to close the modal. However, with a little bit of JavaScript, you can also close the modal when clicking outside of the modal box:

Example

// Get the modal
var modal = document.getElementById('id01');

// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
  if (event.target == modal) {
    modal.style.display = "none";
  }
}

Advanced: Lightbox (Modal Image Gallery)

This example shows how to add an image slideshow inside a modal, to create a "lightbox":

×

Nature and sunrise

Nature and sunrise
French Alps
Mountains and fjords

Example

Click on an image:

Tip: To learn more about slideshows, visit our W3.CSS Slideshow chapter.