The Tridecadal Korean (astralblue) wrote,
The Tridecadal Korean
astralblue

[RawJournal] Lesson #1: Centering <lj-cut> tags while leaving lj-cut contents not centered

How to use:

Copy and paste, replacing TEXT and CONTENTS:

<div style="text-align: center"><lj-cut text="TEXT"></div>CONTENTS<div></lj-cut></div>

Or, easier to read (requires Text Formatting to be None):

<div style="text-align: center"><lj-cut text="TEXT"></div>

CONTENTS

<div></lj-cut></div>

How it works (skip if you don't care):

As you know,

<lj-cut text="A">B</lj-cut>
is replaced by:

<b>( <a href="URL">A</a> )</b>

on the journal view, but simply by:

B

on the entry/comment view.  So, the above construct becomes:

<div style="text-align: center"><b>( <a href="URL">TEXT</a> )<b></div>

in the journal view, and:

<div style="text-align: center"></div>CONTENTS<div></div>

in the entry/comment view.

In the first case, note the first closing and the second opening div tags (both marked in blue) have been removed because they were inside the lj-cut tag pair, so the first opening <div> tag (marked in red) has been matched with the second closing </div> tag (marked in green).  Since the red-blue tag pair encloses exactly the generated HTML code (for parentheses and the hyperlinked TEXT), the generated code is governed by the style the red tag specifies, i.e. it's horizontally centered.

And in the latter case, the centering red <div> tag is terminated right before CONTENTS starts (by a blue div tag), so CONTENTS is not centered.  Furthermore, since the two <div></div> tag pairs are empty, they don't take up any vertical space at all.

Subscribe

  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 0 comments