hexojs / hexo

A fast, simple & powerful blog framework, powered by Node.js.
https://hexo.io
MIT License
39.2k stars 4.82k forks source link

How to set my images align in my articles? #919

Closed seanlook closed 9 years ago

seanlook commented 9 years ago

Of course <center> ![img][link] </center> will work for me, but I don't want to add <center> block every time I have image. I need images set align by default. Could this be accomplished with css or by new markdown's features. ( As I konw {: .center } block could be work for some markdown like python-markdown) Thanks!

xing5 commented 9 years ago

You need to check the CSS of the theme you are using.

The theme Landscape put the image in the center by default. It's controlled by the .article-entry img in $THEME/source/css/_partial/article.styl.

To put the image in the center as default, set its margin to auto.

You can also create CSS classes and explicitly specify the class of the image using img tag.

For example, create a class align-left:

  .align-left
    margin-left: 20px

Apply it:

{% img align-left /PATH/IMAGE/ IMAGE-NAME %}
seanlook commented 9 years ago

I want to use ![][] to keep compatibility with Github Favored Markdown. I don't think GFM would translate {% %}. Any other advice?

wzpan commented 9 years ago

You can try hexo-renderer-pandoc that supports pandoc-markdown.

xing5 commented 9 years ago

With ![][] you can't specify CSS class, so just change the margin of .article-entry img to auto directly.

leesei commented 9 years ago

I concur that theme customization is the solution. Please close this issue.