<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>grid .item#it$*4</title>
</head>
<body>
<article id="testV1">
<section id="result">
<div class="conteneur">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
</section>
</article>
</body>
</html>
.conteneur {
display : grid;
grid-template-columns: 100px 1fr 5vw ;
grid-template-rows: 50px 1fr;
grid-gap : 2px;
}
.item:nth-child(1){
}
.item:nth-child(2){
}
.item:nth-child(3){
}
.item:nth-child(4){
}
#testV1{
}
body:after {
content: "";
position: absolute;
z-index : -1;
top: 0px; right: 0; bottom: 0; left: 0;
background: linear-gradient(0deg, rgba(0,0,0,.05) 1px, transparent 1px),
linear-gradient(0deg, rgba(0,0,0,.1) 1px, transparent 1px),
linear-gradient(90deg, rgba(0,0,0,.05) 1px, transparent 1px),
linear-gradient(90deg, rgba(0,0,0,.1) 1px, transparent 1px);
background-size: 10px 10px, 50px 50px, 10px 10px, 50px 50px;
}
body {
padding:0;
margin:0;
}
#testV1 #result .item {
opacity : 0.7;
padding : 5px;
}
#testV1 .conteneur {
height: 400px;
width: 400px;
border : 1px solid black;
color : white;
resize: both;
overflow: hidden;
position : absolute;
top : 50px;
left : 50px;
font-size : 1em;
}
function proportion(n) {
return function(m) { return (m/n).toFixed(2); };
}
function tick() {
let rapportBody = proportion(document.querySelector('#testV1 .conteneur').offsetWidth);
let I = document.querySelectorAll('#testV1 .item')
for (let i=0 ; i<I.length ; i++){
I[i].textContent = `${I[i].offsetWidth}/${I[i].offsetHeight} \u2192${rapportBody(I[i].offsetWidth)}`;
}
window.requestAnimationFrame(tick);
}
window.requestAnimationFrame(tick);
Array.from(document.querySelectorAll('#testV1 .item'),el => {el.style.backgroundColor = "#"+Math.random().toString(16).slice(2, 8);});
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |