Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <section id="s1">
    <h3>inline-block</h3>
    <div>
      <span></span><span></span>
    </div>
    <input type="text"/>
  </section>
    <section id="s2">
    <h3>block</h3>
    <div>
      <span></span><span></span>
    </div>
    <input type="text"/>
  </section>
  <section id="s3">
    <h3>flex row</h3>
    <div>
      <span></span><span></span>
    </div>
    <input type="text"/>
  </section>
  <section id="s4">
    <h3>flex column</h3>
    <div>
      <span></span><span></span>
    </div>
    <input type="text"/>
  </section>
</body>
</html>
 
div {
  width: 100px;
  height: 100px;
  background: lightgreen;
}
span {
  display: block;
  width: 50px;
  height: 50px;
  /* Add block-end and inline-end margin */
  margin: 0 20px 20px 0;
  background: orange;
  flex-grow: 0;
  flex-shrink: 0;
}
#s1 div {
  white-space: nowrap;
}
#s1 span {
  display: inline-block;
}
#s3 div {
  display: flex;
}
#s4 div {
  display: flex;
  flex-direction: column;
}
body {
  margin-bottom: 100px;
}
 
setInterval(function() {
  for (var i = 1; i <= 4; i++) {
    var target = document.querySelector('#s' + i + ' div');
    var input = document.querySelector('#s' + i + ' input');
    input.value = 'w=' + target.scrollWidth +
      ' h=' + target.scrollHeight;
  }
}, 500);
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers