リンクが張られた画像をLightbox形式で表示するようなJavaScriptを書いていた。vwとvh単位でa要素を引き伸ばして適当に前面に表示し、img要素をなんとなく拡大してから天地左右中央配置する。予めクラス指定が必要だったり、スタイルの追加が必要だったりしない、ドロップインで動作するものだ。 Demo: Lightbox with Clean Markup デモでそれぞれの画像をクリック(タッチ)すると、描画領域全体に画像が表示される。a要素をオーバーレイの背景に変え、img要素をうまく収まるように調整することになる。 if (this.href !== image.src) { image._src = image.src; image.src = this.href; } リンク先と画像のURLが違う場合は、画像がサムネイルでリンク先がフルサイズの画像とみなし、一時的に画像のリ