You are creating a CSS snippet for image alignment in Obsidian! Here’s a concise guide based on your description:
Step-by-Step Guide to Create Image Alignment in Obsidian
Create the CSS File:
Navigate to the snippets folder in your Obsidian vault.
Create a new file named Image Align.css.
Add the CSS Snippet:
Open the Image Align.css file and add the following code: img[alt*=“center”] {
display: block;
margin-left: auto;
margin-right: auto;
}
img[alt*=“right”] {
float: right;
clear: right;
margin-left: 1rem;
margin-bottom: 2px;
margin-top: 2px;
}
Enable the Snippet in Obsidian:
Go to Settings → Appearance.
Scroll down to the CSS Snippets section.
Find the “Image Align” snippet and toggle it on.
Insert Images in Obsidian:
To insert an image in your notes, use the following syntax based on your desired alignment:
Left Alignment: ![[image_name]]
Right Alignment: ![[image_name | right]]
Center Alignment: ![[image_name | center]]
Specify Image Size: You can specify the desired size after the alignment as follows:
Example for center alignment with a specified width: ![[image_name | center | 100]]
That’s exactly what I was looking for! I do have some follow-up questions, though:
Any idea if it’s possible to set a dinamic variable to the image float so that it positions it according to the value you assign to it? That’s not that much of a necessary thing, just curious!