Newer
Older
<div>1</div>
<div>2</div>
<div>3</div>
<div>4</div>
<div>5</div>
<div>6</div>
<div>7</div>
<div>8</div>
<div>9</div>
<div>10</div>
<div>11</div>
<div>12</div>
<div><span>0 (12px) </span></div>
<div><span>1 (24px) </span></div>
<div><span>2 (48px) </span></div>
<div><span>3 (64px) </span></div>
<div><span>4 (128px) </span></div>
<div><span>5 (256px) </span></div>
pointer-events: none;
position: fixed;
margin: auto;
max-width: 100%;
top: 0;
left: 50%;
transform: translateX(-50%);
width: calc(1920px + var(--d-grid-margin));
}
.d-grid.is-visible {
display: grid;
}
.d-grid > div {
border-right: 1px solid yellow;
*/
.d-spacing {
display: none;
position: fixed;
top: 50%;
transform: translateY(-50%);
left: 0;
}
.d-spacing.is-visible {
display: block;
}
.d-spacing > div {
position: relative;
}
.d-spacing > div span {
position: absolute;
}
.d-spacing > div {
width: 100%;
height: var(--spacing0);
}
.d-spacing > div:nth-child(1) span{
margin-top: -10px;
}
.d-spacing > div:nth-child(2){
height: var(--spacing1);
}
.d-spacing > div:nth-child(3){
height: var(--spacing2);
}
.d-spacing > div:nth-child(4){
height: var(--spacing3);
}
.d-spacing > div:nth-child(5){
height: var(--spacing4);
}
.d-spacing > div:nth-child(6){
height: var(--spacing5);
}
.d-cross {
position: fixed;
top: 0;
left: 0;
width: 2px;
height: 2px;
background: gray;
display: none;
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
z-index: 100;
}
.d-cross.is-visible {
display: block;
}
.d-cross:after, .d-cross:before{
content: '';
position: absolute;
background: gray;
transform: translate(-50%, -50%);
width: 1px;
height: 1px;
}
.d-cross:after{
height: 200vh;
}
.d-cross:before{
width: 200vw;
}
@media (max-width: 768px) {
.d-grid > div {
display: none;
}
.d-grid {
border-left: calc(var(--d-grid-sm-margin) / 2) solid fuchsia;
border-right: calc(var(--d-grid-sm-margin) / 2) solid fuchsia;
}
}
</style>
<script>
window.addEventListener('keydown', e => {
if (e.ctrlKey && e.key === 'g') {
document.querySelector('.d-grid').classList.toggle('is-visible');
document.querySelector('.d-spacing').classList.toggle('is-visible');
document.querySelector('.d-cross').classList.toggle('is-visible');
if (e.ctrlKey && e.key === 'w') {
document.body.classList.toggle('full-width');
}
window.addEventListener('pointermove', e => {
document.querySelector('.d-cross').style.left = e.clientX + "px";
document.querySelector('.d-cross').style.top = e.clientY + "px";
});
document.querySelectorAll('img').forEach(img => {
img.addEventListener('click', e => {
if (e.altKey) {
e.preventDefault()
e.stopImmediatePropagation()
responsiveImageDebugOutput(img)
}
})
function responsiveImageDebugOutput(img) {
if (!img) {
throw new TypeError("Expected an image node. Got none.");
}
const listener = function () {
const dimensionWidth = img.naturalWidth * window.devicePixelRatio;
const dimensionHeight = img.naturalHeight * window.devicePixelRatio;
console.log(`
-------------------------
Rendered size: ${img.width}x${img.height}
Intrinsic size: ${dimensionWidth}x${dimensionHeight}
Device Pixel Ratio: ${window.devicePixelRatio}
-------------------------
`);
};
if (img.complete) listener();
//img.addEventListener('load', listener);
}