Mudanças entre as edições de "Widget:Teste"
Ir para navegação
Ir para pesquisar
m Etiqueta: Revertido |
m Etiqueta: Revertido |
||
| Linha 1: | Linha 1: | ||
<!-- Widget:Teste — | <!-- Widget:Teste — apenas CSS+JS para thumbs de GIF --> | ||
--> | |||
<style> | <style> | ||
/* | /* Estilos isolados do “thumb fake” */ | ||
. | .gtr-thumb { margin: .5em 0; } | ||
. | .gtr-thumb.tright { float: right; clear: right; margin-left: 1.4em; } | ||
. | .gtr-thumb.tleft { float: left; clear: left; margin-right: 1.4em; } | ||
. | .gtr-thumb.tcenter { float: none; display: table; margin: .5em auto; } | ||
. | .gtr-thumb .thumbinner { | ||
border: 1px solid #a2a9b1; | border: 1px solid #a2a9b1; | ||
background-color: #f8f9fa; | background-color: #f8f9fa; | ||
| Linha 39: | Linha 17: | ||
} | } | ||
. | .gtr-thumb .thumbimage { | ||
display: block; | display: block; | ||
max-width: 100%; | max-width: 100%; | ||
| Linha 45: | Linha 23: | ||
} | } | ||
. | .gtr-thumb .thumbcaption { | ||
margin-top: 3px; | margin-top: 3px; | ||
font-size: 88%; | font-size: 88%; | ||
| Linha 54: | Linha 32: | ||
<script> | <script> | ||
/* Ajusta automaticamente a largura do .thumbinner quando o template | |||
não fixar width. Funciona para qualquer bloco .gtr-thumb na página. */ | |||
(function () { | (function () { | ||
function fitOne(root) { | |||
try { | |||
var inner = root.querySelector('.thumbinner'); | |||
var img = root.querySelector('img.thumbimage'); | |||
if (!inner || !img) return; | |||
var hasFixed = inner.getAttribute('style') && /width\s*:/.test(inner.getAttribute('style')); | |||
if (hasFixed) return; | |||
function fit() { | |||
var w = Math.round(img.getBoundingClientRect().width); | |||
if (w > 0) inner.style.width = (w + 2) + 'px'; // +2 pela borda (1px de cada lado) | |||
} | |||
if (img.complete) { fit(); } | |||
else { img.addEventListener('load', fit, { once: true }); } | |||
window.addEventListener('resize', fit); | |||
} catch (e) {} | |||
} | |||
if ( | |||
} | |||
function boot() { | |||
document.querySelectorAll('.gtr-thumb').forEach(fitOne); | |||
} | |||
if (document.readyState === 'loading') { | |||
document.addEventListener('DOMContentLoaded', boot); | |||
} else { | |||
boot(); | |||
} | |||
})(); | })(); | ||
</script> | </script> | ||
Edição das 02h07min de 14 de agosto de 2025
<style> /* Estilos isolados do “thumb fake” */ .gtr-thumb { margin: .5em 0; } .gtr-thumb.tright { float: right; clear: right; margin-left: 1.4em; } .gtr-thumb.tleft { float: left; clear: left; margin-right: 1.4em; } .gtr-thumb.tcenter { float: none; display: table; margin: .5em auto; }
.gtr-thumb .thumbinner {
border: 1px solid #a2a9b1; background-color: #f8f9fa; padding: 3px; text-align: center; display: inline-block; max-width: 100%; box-sizing: content-box; /* largura = img + 2px da borda */
}
.gtr-thumb .thumbimage {
display: block; max-width: 100%; height: auto;
}
.gtr-thumb .thumbcaption {
margin-top: 3px; font-size: 88%; color: #202122; line-height: 1.3;
} </style>
<script> /* Ajusta automaticamente a largura do .thumbinner quando o template
não fixar width. Funciona para qualquer bloco .gtr-thumb na página. */
(function () {
function fitOne(root) {
try {
var inner = root.querySelector('.thumbinner');
var img = root.querySelector('img.thumbimage');
if (!inner || !img) return;
var hasFixed = inner.getAttribute('style') && /width\s*:/.test(inner.getAttribute('style'));
if (hasFixed) return;
function fit() {
var w = Math.round(img.getBoundingClientRect().width);
if (w > 0) inner.style.width = (w + 2) + 'px'; // +2 pela borda (1px de cada lado)
}
if (img.complete) { fit(); }
else { img.addEventListener('load', fit, { once: true }); }
window.addEventListener('resize', fit);
} catch (e) {}
}
function boot() {
document.querySelectorAll('.gtr-thumb').forEach(fitOne);
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', boot);
} else {
boot();
}
})(); </script>