Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!--Source from https://www.w3schools.com/howto/howto_css_modals.asp -->
<h2>Ví Dụ Modal</h2>

<!-- Nút Để  Mở Modal -->
<button id="myBtn">Mở Modal</button>

<!-- Modal Cho Website -->
<div id="myModal" class="modal">

  <!-- Nội Dung Modal -->
  <div class="modal-content">
    <span class="close">&times;</span>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur hendrerit sapien dui. Ut mattis ullamcorper quam, vel egestas sem finibus in. Proin semper fermentum ipsum, sed sollicitudin neque ultricies a. Ut interdum leo non lobortis feugiat. Etiam laoreet at libero vel egestas. Nam in dui ac lorem tristique vehicula. Vivamus imperdiet facilisis quam id tincidunt.</p>
  </div>

</div>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP&display=swap');

body {font-family: 'Noto Sans JP', sans-serif;}

/* Thiết Lập Modal Background */
.modal {
  display: none; /* Ẩn Mặc Định */
  position: fixed; 
  z-index: 1; 
  padding-top: 100px; /* Vị trí của modal */
  left: 0;
  top: 0;
  width: 100%; 
  height: 100%; 
  overflow: auto; /* thiết lập scroll khi cần thiết */
  background-color: rgb(0,0,0); 
  background-color: rgba(0,0,0,0.4); 
}
#myBtn {
  background-color: #4CAF50; /* Green */
  border: none;
  color: white;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  margin: 4px 2px;
  cursor: pointer;
  -webkit-transition-duration: 0.4s; /* Safari */
  transition-duration: 0.4s;
   box-shadow: 0 1px 1px rgba(0,0,0,0.12), 
              0 2px 2px rgba(0,0,0,0.12), 
              0 4px 4px rgba(0,0,0,0.12), 
              0 8px 8px rgba(0,0,0,0.12),
              0 16px 16px rgba(0,0,0,0.12);
  outline: none;
}

/* Nội Dung Modal */
.modal-content {
  background-color: #fefefe;
  margin: auto;
  padding: 20px;
  border: 1px solid #888;
  width: 80%;
  box-shadow: 0 1px 1px rgba(0,0,0,0.12), 
              0 2px 2px rgba(0,0,0,0.12), 
              0 4px 4px rgba(0,0,0,0.12), 
              0 8px 8px rgba(0,0,0,0.12),
              0 16px 16px rgba(0,0,0,0.12);
  border-radius: 25px;
}

/* Nút Đóng Modal */
.close {
  color: #aaaaaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
}

.close:hover,
.close:focus {
  color: #000;
  text-decoration: none;
  cursor: pointer;
}
              
            
!

JS

              
                /* lấy phần tử modal */
var modal = document.getElementById("myModal");

/* thiết lập nút mở modal */
var btn = document.getElementById("myBtn");

/* thiết lập nút đóng modal */
var span = document.getElementsByClassName("close")[0];

/* Sẽ hiển thị modal khi người dùng click vào */
btn.onclick = function() {
  modal.style.display = "block";
}

/* Sẽ đóng modal khi nhấn dấu x */
span.onclick = function() {
  modal.style.display = "none";
}

/*Sẽ đóng modal khi nhấp ra ngoài màn hình*/
window.onclick = function(event) {
  if (event.target == modal) {
    modal.style.display = "none";
  }
}
              
            
!
999px

Console