<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Resize observer text test</title>
<style>
html {
height: 100%;
font-family: 'helvetica neue', arial, sans-serif;
}
body {
height: inherit;
margin: 0;
display: flex;
justify-content: center;
align-items: center;
}
body > div {
background-color: #eee;
border: 1px solid #ccc;
padding: 20px;
width: 50%;
min-width: 320px;
}
h1 {
margin: 0;
}
p {
line-height: 1.5;
}
form {
width: 100%;
}
form > div {
display: flex;
}
form label {
flex: 2;
}
form input {
flex: 3;
}
input[type="checkbox"] {
height: 2rem;
}
</style>
</head>
<body>
<div>
<h1>So what happened?</h1>
<p>And remember, don't do anything that affects anything, unless it turns out you were supposed to, in which case, for the love of God, don't not do it! Ow, my spirit! I don't want to be rescued. You guys aren't Santa! You're not even robots. I've got to find a way to escape the horrible ravages of youth. Suddenly, I'm going to the bathroom like clockwork, every three hours. And those jerks at Social Security stopped sending me checks. Now 'I' have to pay 'them'!</p>
<form>
<div><label>Observer enabled:</label><input type="checkbox" checked></div>
<div><label>Adjust width:</label><input type="range" value="600" min="300" max="1300"></div>
</form>
</div>
<script>
if(window.ResizeObserver) {
const h1Elem = document.querySelector('h1');
const pElem = document.querySelector('p');
const divElem = document.querySelector('body > div');
const slider = document.querySelector('input[type="range"]');
const checkbox = document.querySelector('input[type="checkbox"]');
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.