forked from kmaasrud/awesome-obsidian
-
Notifications
You must be signed in to change notification settings - Fork 0
/
media-grid.css
127 lines (112 loc) · 3.97 KB
/
media-grid.css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
IMPORTANT
For information on requirements and how to use this snippet, see its original repo:
https://github.com/zremboldt/obsidian-media-grid
This snippet requires Contextual Typography 2.2.1+
https://github.com/mgmeyers/obsidian-contextual-typography
*/
:root {
--content-base-width: 45rem;
}
/* ----------------------------------------- */
/* Handle overall content width */
/* ----------------------------------------- */
/* Wrapper with padding keeps content from bumping the edges */
.markdown-preview-view {
padding-inline: 30px;
}
/* Container controlling overall max content width */
.markdown-preview-view .markdown-preview-section {
width: 100%;
max-width: var(--content-max-width, 45rem); /* Second value is fallback in case user isn't using Style settings */
}
/* All children of overall container are divs */
.markdown-preview-view .markdown-preview-section > div {
margin-inline: auto;
width: min(var(--content-base-width), 100%);
}
/* Specific children of overall container that contain media */
.markdown-preview-view .markdown-preview-section div[data-is-embed] {
width: 100%;
}
/* ----------------------------------------- */
/* Make media items display in rows */
/* ----------------------------------------- */
/* p tags wrap each row */
.markdown-preview-view .markdown-preview-section div[data-is-embed] > p {
display:grid;
grid-template-columns:repeat(auto-fit, minmax(0, 1fr));
grid-gap: var(--media-grid-gap, 7px);
margin: 0;
}
/* Remove breaks from the document flow */
.markdown-preview-view .markdown-preview-section div[data-is-embed] > p br {
display: none;
}
/* Media items sourced from your vault are wrapped in a span – media linked from the web is not wrapped */
.markdown-preview-view .markdown-preview-section div[data-is-embed] > p > span {
display: flex;
}
/* Apply this to all img/video tags in a row whether they're wrapped in a span or not */
.markdown-preview-view .markdown-preview-section div[data-is-embed] > p img,
.markdown-preview-view .markdown-preview-section div[data-is-embed] > p video {
flex: 1;
align-self: stretch;
object-fit: cover;
border-radius: var(--media-border-radius, 4px);
}
/* Create gaps between rows */
.markdown-preview-view .markdown-preview-section div[data-is-embed] + div[data-is-embed] {
margin-top: var(--media-grid-gap, 7px);
}
/* ----------------------------------------- */
/* Style settings */
/* ----------------------------------------- */
/* @settings
name: Media Grid Snippet
id: media-grid-snippet
settings:
-
id: content-max-width
title: Grid width
description: Set the max width of your grid layouts.
type: variable-select
allowEmpty: false
default: var(--content-base-width)
options:
-
label: Base width
value: var(--content-base-width)
-
label: Small
value: calc(var(--content-base-width) + 5%)
-
label: Medium
value: calc(var(--content-base-width) + 10%)
-
label: Large
value: calc(var(--content-base-width) + 20%)
-
label: Full width
value: 100%
-
id: media-grid-gap
title: Grid gap
description: Set the gap size between items in your grid layouts.
type: variable-number-slider
format: px
default: 7
min: 0
max: 80
step: 1
-
id: media-border-radius
title: Border radius
description: Set the border radius of your images and videos.
type: variable-number-slider
format: px
default: 4
min: 0
max: 40
step: 1
*/