File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -25,3 +25,40 @@ figcaption {
2525 margin-top : 0.5rem ;
2626 font-style : italic ;
2727}
28+
29+ /* CSS-only lightbox. See https://codesalad.dev/blog/how-to-create-an-image-lightbox-in-pure-css-25 */
30+ .lightbox {
31+ /* Default to hidden */
32+ display : none ;
33+
34+ /* Overlay entire screen */
35+ position : fixed ;
36+ z-index : 99999 ;
37+ top : 0 ;
38+ left : 0 ;
39+ right : 0 ;
40+ bottom : 0 ;
41+
42+ /* A bit of padding around image */
43+ padding : 1em ;
44+
45+ /* Translucent background */
46+ background : rgba (0 , 0 , 0 , 1 );
47+ }
48+
49+ /* Unhide the lightbox when it's the target */
50+ .lightbox :target {
51+ display : block ;
52+ }
53+
54+ .lightbox span {
55+ /* Full width and height */
56+ display : block ;
57+ width : 100% ;
58+ height : 100% ;
59+
60+ /* Size and position background image */
61+ background-position : center ;
62+ background-repeat : no-repeat ;
63+ background-size : contain ;
64+ }
Original file line number Diff line number Diff line change 108108 {{- end }}
109109{{- end }}
110110
111+ {{- $lightbox := true }}
112+
111113{{- /* Render image element. */ -}}
114+ {{- if $lightbox -}}
115+ < a href ="#{{ print $id "-lightbox " }}">
116+ {{- end }}
112117< img
113118 {{- range $k, $v : = $attrs }}
114119 {{- if or $v (eq $k "alt") }}
115120 {{- printf " %s=%q " $k $v | safeHTMLAttr }}
116121 {{- end }}
117122 {{- end -}}
118123>
124+ {{- if $lightbox -}}
125+ </ a >
126+ < a href ="javascript:history.back(); " class ="lightbox " id ="{{ print $id "-lightbox " }}">
127+ < img
128+ {{- range $k, $v : = $attrs }}
129+ {{- if or $v (eq $k "alt") }}
130+ {{- printf " %s=%q " $k $v | safeHTMLAttr }}
131+ {{- end }}
132+ {{- end -}}
133+ >
134+ </ a >
135+ {{- end }}
You can’t perform that action at this time.
0 commit comments