CSS snippet to display markdown in grids without HTML

Made a big CSS file to make a lot of different CSS grids using only callouts.

Works in live preview, reading view and in published obsidian website.

Features

  • Grids
  • Grid items as list or callouts or invisible callouts
  • Nested grids
  • Specify up to 8 columns
  • Change all or individual columns sizes
  • Grid items span in columns and rows
  • Grid items alignment
  • Customization : borders, gap, padding, background
  • Options for mobile and tablet

Simple grid

Here is a first example :

Show code
> [!grid-card]
> - This is a simple list inside a special callout called "grid"
> - Each element is a grid item
> - 
> 	- You can have a sub-list
> 	- with multiple elements inside
> 
> > [!grid-item]
> > This is another grid item inside a callout alled "grid-item" as an alternate way
> 
> - You can use both at the same time
> 
> > [!tip]
> > And use any callout as grid item !

And a second one a little more complex

Show code
> [!grid-card]
> > [!grid-item]
> > ### Lorem ipsum dolor
> > sit amet
> > 
> > ---
> > 
> > > Sed ut perspiciatis unde omnis iste natus
> 
> > [!success]
> > consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
> > ```
> > Ut enim ad minim veniam, quis nostrud exercitation
> > ```
> 
> -
> 	- **ullamco laboris nisi ut**
> 	- ***aliquip*** ex ea *commodo* consequat.
> 	- Duis aute irure [[dolor in]]
> 
> > [!grid-item]
> > > [!success]
> > > voluptate velit esse cillum dolore eu fugiat nulla pariatur.
> 
> > [!grid-item]
> > - [x] Excepteur sint occaecat cupidatat
> > 
> > ![Engelbart](https://history-computer.com/ModernComputer/Basis/images/Engelbart.jpg)
> > <small>Engelbart</small>
>
> > [!grid-card-2]
> > - This
> > - is
> > - a nested grid
> > - 🤯

Grid items

Grid items

3 ways to have grid items :

  • Simple lists
  • The special callout called “grid-item”
  • Any other callout
> [!grid-card-3]
> - This is an item
>
> > [!grid-item]
> > This is another item
> 
> > [!info]
> > And this is another item

Options

To customize a grid, add keywords after “grid”.

> [!grid ADD OPTIONS HERE]
Nested grids

… works :slight_smile:

> [!grid-card-2]
> - First grid's item
> 
> > [!grid-card-2]
> > - Second grid's item
> > - Second grid's item
> > - Second grid's item
> 
> > [!grid-card-3]
> > - Third grid's item
> > - Third grid's item
> > - Third grid's item
> 
> - First grid's item

Cards

“card” Is a shortcut for “padding border gap”

> [!grid-2 card]

“grid-card” : Is a shortcut for “grid-3 grid-tablet-2 grid-mobile-1 padding border gap same-width same-height”

> [!grid-card]

Number of columns
> [!grid-auto card]

image

> [!grid-2 card]
> [!grid-3 card]
> [!grid-4 card]
> [!grid-5 card]
> [!grid-6 card]
> [!grid-7 card]
> [!grid-8 card]

Number of columns on tablet / mobile
> [!grid-4 grid-tablet-2 grid-mobile-1 card]
Same width
> [!grid-4 card]

> [!grid-4 card same-width]

Same height
> [!grid-4 card]

> [!grid-4 card same-height]

:warning: Does not work with “grid-auto”

Same height across all rows

> [!grid-4 card same-height-all]

:warning: Does not work with “grid-auto”

Grid columns sizes

By default every column takes the space based on their content.
You can define more space for all column with the all-col- option.
You can define more space for any column with the col- option.

How sizing works :

  • auto keyword means that the column takes the space based on their content
  • A number means that the column takes the number’s fraction of the available space

Changing all columns sizes (all-col- option)

  • You can change how all columns sizes by specifying the all-col- option
  • all-col-auto means every column takes the space based on their content (default behavior)
  • same-width and all-col-1 means every column takes 1 fraction of the available space
  • all-col-2 means every column takes 2 fractions of the available space

Changing individual columns sizes (col- option)

  • You can change how individual columns sizes by specifying the col- option
  • col-1-auto means the first column takes the space based on their content
  • col-1-1 means the first column takes 1 fraction of the available space
  • col-1-3 means the first column takes 3 fractions of the available space
  • col-6-3 means the sixth column takes 3 fractions of the available space

All columns size can be changed based on mobile or tablet with :

  • all-mobile-col- option
  • all-tablet-col- option
  • mobile-col- option
  • tablet-col- option

For example :

col-1-2 means the first column will takes 2 fractions of the space, other columns will take 1 fraction of the space due to all-col-1.

> [!grid-4 card all-col-1 col-1-2]
> - 1
> - 2
> - 3
> - 4

> [!all-col-auto]
> [!all-col-1]
> [!all-col-2]
...
> [!all-col-7]
> [!all-col-8]

> [!col-1-auto]
> [!col-1-1]
> [!col-1-2]
...
> [!col-8-7]
> [!col-8-8]
> [!grid-2 card col-1-3 col-2-1]

> [!grid-3 card col-1-3 col-2-auto col-3-1]

> [!grid-4 card   same-width                col-2-2]

... is the same as ...

> [!grid-4 card   all-col-1                 col-2-2]

... is the same as ...

> [!grid-4 card   col-1-1 col-3-1 col-4-1   col-2-2]

> [!grid-4 card                  col-2-1]

... is the same as ...

> [!grid-4 card   all-col-auto   col-2-1]

> [!grid-3 card all-col-2 col-3-1]

> [!grid-3 card all-col-1 col-3-2  grid-tablet-2 tablet-col-2-1   grid-mobile-1]

On PC :


On Tablet :
On Mobile : image

Grid items span

A grid item can span up to 8 columns and 8 rows with col-span- and row-span-

> [!grid-5 card same-width same-height]
> - [1]
> 	- [1]
> 
> - [2]
> 
> > [!grid-item col-span-2]
> > [3] Spanning 2 columns
>
> > [!grid-item row-span-3]
> > [4] Spanning 3 rows
> 
> > [!grid-item col-span-2 row-span-2]
> > [5] Spanning 2 columns and 2 rows
> 
> - [6]
> 	- [6]
> - [7]
> - [8]
> - [9]

> > [!grid-item col-span-2]
> > [!grid-item col-span-3]
> > [!grid-item col-span-4]
> > [!grid-item col-span-5]
> > [!grid-item col-span-6]
> > [!grid-item col-span-7]
> > [!grid-item col-span-8]
> > [!grid-item row-span-2]
> > [!grid-item row-span-3]
> > [!grid-item row-span-4]
> > [!grid-item row-span-5]
> > [!grid-item row-span-6]
> > [!grid-item row-span-7]
> > [!grid-item row-span-8]

Borders
> [!grid-4]

> [!grid-4 border]

Gap
> [!grid-4 border]

> [!grid-4 border gap]

Padding
> [!grid-4 border gap]

> [!grid-4 border gap padding]

Background
> [!grid-4 border gap padding bg]
Alignment
> [!grid-4 border gap]

> [!grid-4 border gap center]

> [!grid-4 border gap right]

> [!grid-4 card same-height top]

> [!grid-4 card same-height middle]

> [!grid-4 card same-height bottom]

> [!grid-4 card same-height center middle]

Only show on mobile / tablet / pc
> [!grid-2 card pc-only]
> [!grid-2 card tablet-only]
> [!grid-2 card mobile-only]
Hide on mobile / tablet / pc
> [!grid-2 card hide-on-pc]
> [!grid-2 card hide-on-tablet]
> [!grid-2 card hide-on-mobile]

Changelog

Changelog
  • 1.0 : Initial version
  • 1.1 : Thanks to Fred_V (CSS snippet to display markdown in grids without HTML - #2 by Fred_V)
    • Added : “bg” option to add background color, added by default to the “card” option
    • Added : “top”, “middle” and “bottom” options for vertical alignment
    • Fixed : Multiple grids in a row were sticked, added some gap between them
    • Fixed : Added a greater gap in the bottom of the grid
    • Fixed : Remove default margin added by ul, ol, p inside grids
  • 1.2 :
    • Added : “grid-card-3” and “grid-card-2” for 2 new templates
    • Added : “li” to create grids with simple lists instead of callouts
  • 1.3 :
    • Fixed : Remove bullets in “li” callout items in preview mode
  • 1.4 :
    • Fixed : margin fix was not applyed on “grid-item” with other options
    • Refactored : simplify code using CSS nesting selectors
  • 2.0 :
    • Removed : “li” as callout option
    • Added : Now supports both lists AND callouts as grid items
    • Added : Now supports any callout as grid item, other callout’s style is not overridden
  • 2.1 :
    • Added : “col-1-1” to “col-8-8” for column sizes
    • Added : “col-1-auto” to “col-8-auto” for auto column sizes
    • Added : “mobile-col-” and “tablet-col-” for responsive column sizes
    • Added : “all-col-auto” and “all-col-1” to “all-col-8” for all columns sizes
    • Added : “all-mobile-col-” and “all-tablet-col-” for responsive column sizes
    • Added : “col-span-1” to “col-span-8” for individual column span
    • Added : “row-span-1” to “row-span-8” for individual column span

CSS file

callout-grid-2.1.css (40.6 KB)

Older versions

Testing markdown file

Markdown file I used for testing this :

Grid test 2.1.md (21.6 KB)

Older versions
4 Likes

Thanks.

This line is not supposed to be used as is, right?

> [!grid-2 grid-3 grid-4 grid-5 grid-6 grid-7 grid-8 card]

This is awesome !

Here are some fixes and additions:

  • customize opacity and color of border and background
  • added options:
    • bg to add background color. It is used by default with card
    • vertical alignment with middle, top, bottom
  • [fix] if using multiple grids in a row, add some gap between them (:30)
  • [fix] add greater gap in the bottom (:22)
  • [experimental] by default lists and other elements in callouts have too much margin-block, avoid that (:59)
/* [Callout] simple grid-card.	css */
/* how to use this: https://forum.obsidian.md/t/css-hack-to-display-markdown-content-in-grids-without-html/95117 */
/* Callout grid */

body {
	--x-grid-padding: 0.6em;
	--x-grid-border-width: 1px;
	--x-grid-border-radius: var(--callout-radius, 3px);
	--x-grid-border-opacity: 80%;
	--x-grid-bg-opacity: 15%;
	--x-grid-border-color: hsla(200, 15%, 39%, var(--x-grid-border-opacity));
	--x-grid-bg-color: hsla(200, 15%, 39%, var(--x-grid-bg-opacity));
	--x-grid-gap: 0.75rem;
}

:is(.el-div, .markdown-rendered) {
	/* Hide callout and main background */
	& > .callout[data-callout*="grid"] {
		background-color: transparent !important;
	}

	/* add margin bottom */
	&:has(> .callout[data-callout*="grid"]) {
		&:has(+ *:not(.el-div, .el-hr)) {
			margin-block-end: 2rem;
		}
	}
}

/* add margin between multiple grid callouts */
.el-div:has(.callout[data-callout*="grid"]) + .el-div {
	margin-block-start: var(--x-grid-padding);
}

.callout[data-callout*="grid"],
.callout[data-callout*="grid"] > .callout-content {
	padding: 0;
	margin: 0;
	border: 0;
	background-color: transparent;
}
.markdown-source-view.mod-cm6 .callout-content .callout[data-callout*="grid"] {
	margin: 0;
}
.callout[data-callout*="grid"] > .callout-title {
	display: none;
}

/* display grid */

.callout[data-callout*="grid"]:not(
		[data-callout*="grid-item"],
		[data-callout*="grid-auto"]
	)
	> .callout-content {
	display: grid;
}

/* by default lists and other elements in callouts have too much margin-block, avoid that */
.callout[data-callout*="grid"]
	> .callout-content
	> [data-callout="grid-item"]
	> .callout-content
	> :is(ul, ol, p) {
	/* margin: 0 !important; */
	margin-block: var(--x-grid-padding) !important;
}

/* Same width */

.callout[data-callout*="grid"] {
	--x-grid-sizing: auto;
}

.callout[data-callout*="grid"]:is(
		[data-callout*="same-width"],
		[data-callout*="grid-card"]
	) {
	--x-grid-sizing: 1fr;
}

/* grid : specific number of columns */

.callout[data-callout*="grid-1"] > .callout-content {
	grid-template-columns: var(--x-grid-sizing);
}

.callout[data-callout*="grid-2"] > .callout-content {
	grid-template-columns: var(--x-grid-sizing) var(--x-grid-sizing);
}

.callout:is([data-callout*="grid-3"], [data-callout*="grid-card"])
	> .callout-content {
	grid-template-columns: var(--x-grid-sizing) var(--x-grid-sizing) var(
			--x-grid-sizing
		);
}

.callout[data-callout*="grid-4"] > .callout-content {
	grid-template-columns:
		var(--x-grid-sizing) var(--x-grid-sizing) var(--x-grid-sizing)
		var(--x-grid-sizing);
}

.callout[data-callout*="grid-5"] > .callout-content {
	grid-template-columns:
		var(--x-grid-sizing) var(--x-grid-sizing) var(--x-grid-sizing)
		var(--x-grid-sizing) var(--x-grid-sizing);
}

.callout[data-callout*="grid-6"] > .callout-content {
	grid-template-columns:
		var(--x-grid-sizing) var(--x-grid-sizing) var(--x-grid-sizing)
		var(--x-grid-sizing) var(--x-grid-sizing) var(--x-grid-sizing);
}

.callout[data-callout*="grid-7"] > .callout-content {
	grid-template-columns:
		var(--x-grid-sizing) var(--x-grid-sizing) var(--x-grid-sizing)
		var(--x-grid-sizing) var(--x-grid-sizing) var(--x-grid-sizing) var(
			--x-grid-sizing
		);
}

.callout[data-callout*="grid-8"] > .callout-content {
	grid-template-columns:
		var(--x-grid-sizing) var(--x-grid-sizing) var(--x-grid-sizing)
		var(--x-grid-sizing) var(--x-grid-sizing) var(--x-grid-sizing) var(
			--x-grid-sizing
		)
		var(--x-grid-sizing);
}

@media screen and (min-width: 750px) and (max-width: 1000px) {
	.callout[data-callout*="grid-tablet-1"] > .callout-content {
		grid-template-columns: var(--x-grid-sizing);
	}

	.callout:is([data-callout*="grid-tablet-2"], [data-callout*="grid-card"])
		> .callout-content {
		grid-template-columns: var(--x-grid-sizing) var(--x-grid-sizing);
	}

	.callout[data-callout*="grid-tablet-3"] > .callout-content {
		grid-template-columns: var(--x-grid-sizing) var(--x-grid-sizing) var(
				--x-grid-sizing
			);
	}

	.callout[data-callout*="grid-tablet-4"] > .callout-content {
		grid-template-columns:
			var(--x-grid-sizing) var(--x-grid-sizing) var(--x-grid-sizing)
			var(--x-grid-sizing);
	}

	.callout[data-callout*="grid-tablet-5"] > .callout-content {
		grid-template-columns:
			var(--x-grid-sizing) var(--x-grid-sizing) var(--x-grid-sizing)
			var(--x-grid-sizing) var(--x-grid-sizing);
	}

	.callout[data-callout*="grid-tablet-6"] > .callout-content {
		grid-template-columns:
			var(--x-grid-sizing) var(--x-grid-sizing) var(--x-grid-sizing)
			var(--x-grid-sizing) var(--x-grid-sizing) var(--x-grid-sizing);
	}

	.callout[data-callout*="grid-tablet-7"] > .callout-content {
		grid-template-columns:
			var(--x-grid-sizing) var(--x-grid-sizing) var(--x-grid-sizing)
			var(--x-grid-sizing) var(--x-grid-sizing) var(--x-grid-sizing) var(
				--x-grid-sizing
			);
	}

	.callout[data-callout*="grid-tablet-8"] > .callout-content {
		grid-template-columns:
			var(--x-grid-sizing) var(--x-grid-sizing) var(--x-grid-sizing)
			var(--x-grid-sizing) var(--x-grid-sizing) var(--x-grid-sizing) var(
				--x-grid-sizing
			)
			var(--x-grid-sizing);
	}
}

@media screen and (max-width: 750px) {
	.callout:is([data-callout*="grid-mobile-1"], [data-callout*="grid-card"])
		> .callout-content {
		grid-template-columns: var(--x-grid-sizing);
	}

	.callout[data-callout*="grid-mobile-2"] > .callout-content {
		grid-template-columns: var(--x-grid-sizing) var(--x-grid-sizing);
	}

	.callout[data-callout*="grid-mobile-3"] > .callout-content {
		grid-template-columns: var(--x-grid-sizing) var(--x-grid-sizing) var(
				--x-grid-sizing
			);
	}

	.callout[data-callout*="grid-mobile-4"] > .callout-content {
		grid-template-columns:
			var(--x-grid-sizing) var(--x-grid-sizing) var(--x-grid-sizing)
			var(--x-grid-sizing);
	}

	.callout[data-callout*="grid-mobile-5"] > .callout-content {
		grid-template-columns:
			var(--x-grid-sizing) var(--x-grid-sizing) var(--x-grid-sizing)
			var(--x-grid-sizing) var(--x-grid-sizing);
	}

	.callout[data-callout*="grid-mobile-6"] > .callout-content {
		grid-template-columns:
			var(--x-grid-sizing) var(--x-grid-sizing) var(--x-grid-sizing)
			var(--x-grid-sizing) var(--x-grid-sizing) var(--x-grid-sizing);
	}

	.callout[data-callout*="grid-mobile-7"] > .callout-content {
		grid-template-columns:
			var(--x-grid-sizing) var(--x-grid-sizing) var(--x-grid-sizing)
			var(--x-grid-sizing) var(--x-grid-sizing) var(--x-grid-sizing) var(
				--x-grid-sizing
			);
	}

	.callout[data-callout*="grid-mobile-8"] > .callout-content {
		grid-template-columns:
			var(--x-grid-sizing) var(--x-grid-sizing) var(--x-grid-sizing)
			var(--x-grid-sizing) var(--x-grid-sizing) var(--x-grid-sizing) var(
				--x-grid-sizing
			)
			var(--x-grid-sizing);
	}
}

/* grid-auto : auto number of columns */

.callout[data-callout*="grid-auto"] > .callout-content {
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
}

/* Padding */

.callout[data-callout*="grid"]:is(
		[data-callout*="padding"],
		[data-callout*="card"]
	)
	> .callout-content
	> .callout[data-callout*="grid-item"]
	> .callout-content {
	padding: 0 var(--x-grid-padding, var(--p-spacing));
}

/* Background color */

.callout[data-callout*="grid"]:is([data-callout*="bg"], [data-callout*="card"])
	> .callout-content
	> .callout[data-callout*="grid-item"] {
	background-color: transparent !important;
	& > .callout-content {
		background-color: var(--x-grid-bg-color) !important;
	}
}

.callout[data-callout*="grid"]:not([data-callout*="bg"], [data-callout*="card"])
	> .callout-content
	> .callout[data-callout*="grid-item"],
.callout[data-callout*="grid-item"] > .callout-content {
	background-color: transparent !important;
}

/* Border */

.callout[data-callout*="grid"]:is(
		[data-callout*="border"],
		[data-callout*="card"]
	)
	> .callout-content
	> .callout[data-callout*="grid-item"]
	> .callout-content {
	border-radius: var(--x-grid-border-radius, 0);
	border: var(--x-grid-border-width) solid var(--x-grid-border-color) !important;
}

/* Gap */

.callout[data-callout*="grid"]:is([data-callout*="gap"], [data-callout*="card"])
	> .callout-content {
	grid-gap: var(--x-grid-gap);
}

/* Same height */

.callout[data-callout*="grid"]:is(
		[data-callout*="same-height"],
		[data-callout*="grid-card"]
	):not([data-callout*="grid-item"])
	> .callout-content
	> .callout[data-callout*="grid-item"]
	> .callout-content {
	/* Takes parent size */
	height: 100%;
	width: 100%;
}

/* Same height in all rows */

.callout[data-callout*="grid"][data-callout*="same-height-all"]
	> .callout-content {
	grid-auto-rows: 1fr;
}

/* Center */

.callout[data-callout*="grid"][data-callout*="center"]
	> .callout-content
	> .callout[data-callout*="grid-item"]
	> .callout-content {
	text-align: center;
}
.callout[data-callout*="grid"][data-callout*="center"]
	> .callout-content
	> .callout[data-callout*="grid-item"]
	> .callout-content
	> :is(.callout, pre, [class*="block-language"]) {
	/* Don't align text center inside nested callouts / code blocks */
	text-align: left;
}
.callout[data-callout*="grid"][data-callout*="center"]
	> .callout-content
	> .callout[data-callout*="grid-item"]
	> .callout-content
	> :is(ul, ol) {
	/* Center lists */
	display: table;
	margin-right: auto;
	margin-left: auto;
}

/* Right */

.callout[data-callout*="grid"][data-callout*="right"]
	> .callout-content
	> .callout[data-callout*="grid-item"]
	> .callout-content {
	text-align: right;
}
.callout[data-callout*="grid"][data-callout*="right"]
	> .callout-content
	> .callout[data-callout*="grid-item"]
	> .callout-content
	> :is(.callout, pre, [class*="block-language"]) {
	/* Don't align text right inside nested callouts / code blocks */
	text-align: left;
}
.callout[data-callout*="grid"][data-callout*="right"]
	> .callout-content
	> .callout[data-callout*="grid-item"]
	> .callout-content
	> :is(ul, ol) {
	/* Align right lists */
	display: table;
	margin-left: auto;
}

/* Middle : vertical align */

.callout[data-callout*="grid"][data-callout*="middle"]
	> .callout-content
	> .callout[data-callout*="grid-item"]
	> .callout-content {
	display: flex;
	align-items: center;
}

/* Bottom : vertical align */

.callout[data-callout*="grid"][data-callout*="bottom"]
	> .callout-content
	> .callout[data-callout*="grid-item"]
	> .callout-content {
	display: flex;
	align-items: end;
}

/* Top : vertical align */

.callout[data-callout*="grid"][data-callout*="top"]
	> .callout-content
	> .callout[data-callout*="grid-item"]
	> .callout-content {
	display: flex;
	align-items: baseline;
}

/* Hide PC / Tablet / Mobile */

@media screen and (min-width: 1000px) {
	.callout[data-callout*="grid"]:is(
			[data-callout*="hide-on-pc"],
			[data-callout*="tablet-only"],
			[data-callout*="mobile-only"]
		) {
		display: none;
	}
}

@media screen and (min-width: 750px) and (max-width: 1000px) {
	.callout[data-callout*="grid"]:is(
			[data-callout*="hide-on-tablet"],
			[data-callout*="pc-only"],
			[data-callout*="mobile-only"]
		) {
		display: none;
	}
}

@media screen and (max-width: 750px) {
	.callout[data-callout*="grid"]:is(
			[data-callout*="hide-on-mobile"],
			[data-callout*="tablet-only"],
			[data-callout*="pc-only"]
		) {
		display: none;
	}
}

Example

!grid-2 bg gap: bg adds the background color defined in the snippet

!grid-2 card middle same-height-all , align content vertically. Possible values: middle , top , bottom.

!grid-2 card bottom same-height-all , example with bottom.


IMPORTANT

If background color of block code and other custom things don’t display as expected in callout, add this line to this snippet or the one you might use to customize your callouts:

body {
	--callout-blend-mode: normal !important;
}
1 Like

Amazing . :saluting_face: …

You are right, I typed it too quickly :^)

Neat additions ! I will add them in the post and credit you of course :smiley:

I also though about some little changes, more later.

Added :

  • 1.1 : Thanks to Fred_V (CSS Hack to display markdown content in grids without HTML - #2 by Fred_V)
    • Added : “bg” option to add background color, added by default to the “card” option
    • Added : “top”, “middle” and “bottom” options for vertical alignment
    • Fixed : Multiple grids in a row were sticked, added some gap between them
    • Fixed : Added a greater gap in the bottom of the grid
    • Fixed : Remove default margin added by ul, ol, p inside grids
  • 1.2 :
    • Added : “grid-card-3” and “grid-card-2” for 2 new templates
    • Added : “li” to create grids with simple lists instead of callouts
1 Like

Forgot to tell you this :

  1. I didn’t add your « !important » css rules to prevent breaking compatibility with other themes / snippets (related : Specificity - CSS: Cascading Style Sheets | MDN). Do you use a special theme ? I can create a section dedicated to themes’ compatibility.
  2. Your middle and bottom rules were slightly wrong: you forgot flex-direction: column if you have multiple lines

The rest was added, I just added a variable for the margin :slight_smile:

Wow.

Quick question:
Is this going to be able to supersede plugins to do with columns (Obsidian Columns and its predecessor), and Efemkay’s modular CSS (which I and others found to be making larger vaults sluggish)?

To do columns, yes. I haven’t implemented yet a way to have more control over the grid item’s width but it looks like this CSS can do the same.

This CSS snippet uses CSS grid layout where obsidian columns and ef modular css uses CSS flex layout ; both are valid options to use for “columns”.

My guess to why you and others find these css plugins sluggish might be their implementation / additional features but ultimately, they use the same things as I do.

I quickly checked their code and for example ef modular css’s Multi columns is using a lot of complex css selectors such as :has (90+ occurrences only in Multi columns). Combined with other ways to control the style might be why.

If you find this snippet slow you can notify me so I can investigate the cause (if I have the time…).

1 Like

With the lists version, I have this issue where bullet points displayed:

I don’t know why. It’s not the theme. Maybe another snippet but I don’t think so.

The fix is adding:

[data-callout*="grid"][data-callout*="li"] > .callout-content > .has-list-bullet > li > span[class*="list"],
[data-callout*="grid"][data-callout*="li"] > .callout-content > .has-list-bullet > li > .has-list-bullet > li > span[class*="list"] {
  display: none !important;
}


If you are like me and use a snippet to customize the callouts color like:

/* [Callout] better style.css */
/* customization for dark theme */

body.theme-dark.css-settings-manager {
  .callout {
    /* normal blend mode allows to use true color inside callout */
    --callout-blend-mode: normal;

    /* custom options */
    --custom-bg-opacity: 0.12;

    /* override built-in colors and properties */
    --callout-border-width: 2px;
    --callout-border-opacity: 0.2;
    --callout-radius: 3px;
    --icon-stroke: 2.5px;

    --callout-warning: 255, 160, 0;
    --callout-quote: 150, 150, 150;
    --callout-question: 0, 255, 255;
    --callout-success: 0, 230, 95;
    --callout-summary: 230, 230, 230;
    --callout-important: 255, 240, 0;
    --callout-tip: 255, 50, 255;
    --callout-info: 70, 150, 255;
    --callout-todo: 200, 150, 255;
    --callout-example: 150, 100, 255;
    --callout-fail: 255, 100, 100;
    --callout-error: 255, 100, 100;
    --callout-bug: 255, 100, 100;

    /* custom apparence */
    background-color: rgba(var(--callout-color), var(--custom-bg-opacity));
  }
}

Then, you will need to add in your “[Callout] better style.css” :

/* If you want to customize the default margins and paddings */
/* global paddings and margins excluding “[Callout] simple grid-card.css” */
*:not(li) > .callout:not(.is-collapsed, [data-calloutmanager-changelog-callout], [data-callout*="grid"]) {
  padding-block: 0.8em 0.4em;
  & > .callout-content {
    margin-block: -1em;
  }
}

/* Don’t apply color on grid callout customized with “[Callout] simple grid-card.css” */
[data-callout*="grid"] {
  background: none !important;
}
1 Like

You are right, the list’s bullets were displayed in reading view and weren’t in live edit mode.

Quite proud of this one, new in version 2.0 :

  • Removed : “li” as callout option
  • Added : Now supports both lists AND callouts as grid items
  • Added : Now supports any callout as grid item, other callout’s style is not overridden
2 Likes

Thanks again for this.

I can confirm that the slow Backlinks result display issue resulting from issue leveraging another similar CSS snippet I mentioned here is not experienced with the usage of your snippet (ver. 2.1).

  • I have individual files with 600 and more, even 1100 backlinks. So I can see how fast the results are displayed. So not many people would know how to check this.

Employing your method, I have eliminated the need to use FMK’s Multi Columns and plugins like Obsidian Columns.

Cheers

1 Like

I found out an incompatibility with the vimium plugin. When the snippet is enabled, calling the vimium markers is very slow, unusable. The problem is mostly do to the vimium plugin.

Fix

Replace your Your-Vault\.obsidian\plugins\vimium with the content of this patch.
vimium.zip (4.0 KB)
It includes a PR that the plugin author didn’t merge yet.