efemkay / obsidian-modular-css-layout

CSS Layout hack for Obsidian.md
https://efemkay.github.io/obsidian-modular-css-layout/
GNU General Public License v3.0
974 stars 74 forks source link

width of a callout #92

Closed Tanjamuse closed 3 months ago

Tanjamuse commented 3 months ago

is there anyway to change this to percentage of the window instead of amount of callouts?

/* metadata "wide-x" to control subcallout flexible max width. only discrete 2,4,8,16 */ div[data-callout="multi-column"].callout > .callout-content > div[data-callout-metadata*="min-0"] { flex-basis: 0; } div[data-callout="multi-column"].callout > .callout-content > div[data-callout-metadata*="wide-2"] { flex-grow: 2; } div[data-callout="multi-column"].callout > .callout-content > div[data-callout-metadata*="wide-3"] { flex-grow: 3; } div[data-callout="multi-column"].callout > .callout-content > div[data-callout-metadata*="wide-4"] { flex-grow: 4; } div[data-callout="multi-column"].callout > .callout-content > div[data-callout-metadata*="wide-5"] { flex-grow: 5; }

Thank you so much in advance.

efemkay commented 3 months ago

sorry if i misunderstood you since you pasted the css code instead of markdown notes. i try to answer from two perspective.

from programmer perspective, you definitely can. but because the way i manage this so that it depends on parent's div width and using flex-grow: 1, the current setup will not work. you will need to tweak the flex-grow properties and then define the flex-basis to percentage basis e.g. flex-basis: 30%.

from mcl user perspective, i already has this ability to do so but hasn't advertise it. primarily i wanted to wait until i optimise the performance part of it abit. but since you ask, you can do this by defining the multi-column parent callout with callout-metadata of pwx where x is a whole number from 1 to 9. sample below.

the top part is MCC without width control specified, so it behaves just like wide-x version. the bottom part has the parent MCC defined the callout metadata as pw5 which is 50% width of its parent (in this case, note's readable line length). the documentation is still WIP but could be useful for now

image

Tanjamuse commented 3 months ago

This is brilliant and exactly what I was looking for. Thank you so much for your quick reply and for the amazing snippets.