Markdown and image alignment

前端 未结 14 2400
予麋鹿
予麋鹿 2020-12-02 04:06

I am making a site that publishes articles in issues each month. It is straightforward, and I think using a Markdown editor (like the WMD one here in Stack Overflow) wo

14条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-02 04:58

    I found a nice solution in pure Markdown with a little CSS 3 hack :-)

    ![image alt >](/image-right.jpg)
    ![image alt <](/image-left.jpg)
    ![image alt ><](/center-image.jpg)
    

    Follow the CSS 3 code float image on the left or right, when the image alt ends with < or >.

    img[alt$=">"] {
      float: right;
    }
    
    img[alt$="<"] {
      float: left;
    }
    
    img[alt$="><"] {
      display: block;
      max-width: 100%;
      height: auto;
      margin: auto;
      float: none!important;
    }
    

提交回复
热议问题