Skip to content

Commit d7ede49

Browse files
committed
Specify the image location gracefully.
1 parent d0d0780 commit d7ede49

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

_posts/2019-08-08-text-and-typography.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ math: true
88
image: /assets/img/sample/devices-mockup.png
99
---
1010

11-
This Jekyll template totally compatible with Markdown syntax. Now, let's have a look at the text and typography.
11+
This article is to show markdown syntax rendering on [**Chirpy**](https://github.com/cotes2020/jekyll-theme-chirpy/fork), you can also use it as an example of writing. Now, let's start looking at text and typography.
1212

1313

1414
## Titles
@@ -89,11 +89,17 @@ You can change the size of the picture:
8989
![Desktop View](/assets/img/sample/mockup.png){: width="400"}
9090
_400px image width_
9191

92-
In addition, you can use custom styles to change the image position (do not use caption in this case):
92+
In addition, you can use class `left` or `right` to specify the image position (but in this case, the image caption is prohibited), for example:
9393

94-
![Desktop View](/assets/img/sample/mockup.png){: width="200" style="float: left; margin: .75rem 1rem 1rem 0"}
95-
_A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space._
94+
- To the left
9695

96+
![Desktop View](/assets/img/sample/mockup.png){: width="240" class="left"}
97+
"A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space."
98+
99+
- To the right
100+
101+
![Desktop View](/assets/img/sample/mockup.png){: width="240" class="right"}
102+
"A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space. A repetitive and meaningless text is used to fill the space."
97103

98104
## Inline code
99105

assets/css/_addon/main.scss

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -817,12 +817,24 @@ div.post-content .table-wrapper {
817817
overflow-wrap: break-word;
818818
word-wrap: break-word;
819819

820-
@mixin img {
820+
@mixin img($caption: false) {
821821
> img {
822822
&:not([style]) {
823-
margin: .5rem 0;
824-
@include align-center;
825-
@include img-caption;
823+
&:not(.left):not(.right) {
824+
margin: .5rem 0;
825+
@include align-center;
826+
@if $caption {
827+
@include img-caption;
828+
}
829+
}
830+
&.left {
831+
float: left;
832+
margin: .75rem 1rem 1rem 0;
833+
}
834+
&.right {
835+
float: right;
836+
margin: .75rem 0 1rem 1rem;
837+
}
826838
}
827839
}
828840
}
@@ -854,7 +866,7 @@ div.post-content .table-wrapper {
854866

855867
p {
856868
font-size: 1.08rem;
857-
@include img;
869+
@include img(true);
858870
}// p
859871
}
860872

0 commit comments

Comments
 (0)