Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <body>
	<main>
		<h1>Использование диалоговых окон с помощью html-элемента &lt;dialog&gt;</h1>
		<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Veniam magni nostrum, dolore non ducimus aliquam possimus officiis quisquam recusandae molestiae iusto rerum libero et, earum laborum, eius provident cumque atque?</p>
		<p>Voluptates, voluptate quas nulla quisquam maxime error possimus fugit beatae placeat doloribus odit, sequi numquam expedita ut totam earum officia corrupti iste adipisci harum? Distinctio accusantium quam nisi et. Laborum.</p>
	</main>
	<dialog id="dialog1" open>
			<h2>Диалоговое окно №1</h2>
			<p>Атрибут open позволяет сразу отобразить окно, но без заднего фона.</p>
		<button id="closeDialog1">Закрыть окно</button>
	</dialog>

	<dialog id="dialog2">
			<h2>Модальное окно №2</h2>
			<p>Это окно с помощью элемента	   <code>dialog</code> открывается с задним фоном.</p>
		<p>Нажмите клавишу ESC для скрытия окна или кликните в любом месте.</p>
	</dialog>
	<button>Открыть dialog 1</button>
	<button>Открыть dialog 2</button>
	
</body>
              
            
!

CSS

              
                :root {
  --blue: #08a7d8;
  --dark-blue: #0e678c;
}
* {
	box-sizing: border-box;
}
body {
  height: 97vh;
  text-align: center;
  background-color: var(--blue);
	margin: 40px 20px;
}
button {
	display: inline-block;
	margin: 30px 15px 0;
  padding: 15px 35px;
  cursor: pointer;
  border-radius: 30px;
  background: #fff;
  font-size: 20px;
  border: 2px solid var(--dark-blue);
  color: var(--dark-blue);
	box-shadow: 0 8px 8px rgba(6,84,112,.58);
  letter-spacing: 1px;
  line-height: 1;
  transition: background 300ms ease, color 300ms ease;
}
button:hover {
  background: var(--dark-blue);
  color: #fff;
}
main {
	max-width: 700px;
	margin: auto;
}
h1, h2 {
  font-size: 1.5em;
  font-weight: 500;
  margin-top: 0;
}

p {
  margin-bottom: 0;
	line-height: 1.5;
}
dialog {
	max-width: 50%;
  padding: 35px;
  border-radius: 5px;
  border: 0;
}
dialog::backdrop  {
 background: conic-gradient(rgba(128,128, 128, .5), rgba(255, 255,255,.7), var(--dark-blue), black);
}
dialog[open], dialog::backdrop {
  animation: show 500ms ease;
}
@keyframes show {
  0% {
    opacity: 0;
  }
}
              
            
!

JS

              
                let [main, dialog1, dialog2, button1, button2] = document.body.children;

button1.addEventListener('click', () => dialog1.show());

button2.addEventListener('click', () => dialog2.showModal());

document.body.addEventListener('click', ({target}) =>   target === dialog2 && target.close());

closeDialog1.addEventListener('click', event => dialog1.close() )
              
            
!
999px

Console