Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="paragraph">
  <div class="sentence">
    <span class="CharaName">
      ふりがな有
    </span>
    <p class="l1">テスト<ruby>テスト<rt>ふりがな</rt></ruby>テストテスト
テストテストテストテスト
テストテストテストテスト</p>
  </div>
  <div class="sentence">
    <span class="CharaName">
      ふりがな有
    </span>
    <p class="l1">
テストテストテストテスト
テスト<ruby>テスト<rt>ふりがな</rt></ruby>テストテスト
テストテストテストテスト
  </p>
  </div>
  <div class="sentence">
    <span class="CharaName">
      ふりがな無
    </span>
    <p class="l1">テストテストテスト
テストテストテスト
テスト</p>
  </div>
</div>
              
            
!

CSS

              
                .sentence p{
  white-space: pre;
  position: relative;
  background: #fff;
  margin-left:10px;
  border-radius:10px;
  padding: 10px 15px 7.5px 15px;/* ⇦こちらの10pxが上の空白です*/
  width: max-content;
  border: 1px solid;
  display: inline-block;
}

.sentence .l1{
  border:solid 1px;
}

.sentence .l1:before,
.sentence .l1:after{
  content: ""; position: absolute;
}

.sentence .l1:before {
  top: 22px; left: -13px;
  margin-top: -12px;
  border: 5px solid transparent;
  border-right: 10px solid #FFF;
  z-index: 2;
}

.sentence .l1:after {
  top: 23px; left: -15px;
  margin-top: -13px;
  border: 5px solid transparent;
  border-right: 10px solid #555;
}

.sentence p rt {
  transform: translateY(3px);
}

.sentence {
  display:flex;
  position:relative;
  margin-top:-15px
}

/* 名前欄 */
.sentence .CharaName{
  display: inline-block;
  width:4em;
  padding:1.6em 0.5em 0.5em 0.5em;
  text-align: right;
}
              
            
!

JS

              
                let p = document.querySelectorAll('.sentence p');
for (var i = 0; i < p.length; i++) {
  p[i].innerHTML = p[i].innerHTML.trim(); //前後の空白と改行削除
  const rt = p[i].querySelector('rt');
  if ((rt !== null) && (rt.getBoundingClientRect().top - p[i].getBoundingClientRect().top) < 20) {
    p[i].style.paddingTop = "0px";
  };
}


              
            
!
999px

Console