LoginSignup
0
0

More than 3 years have passed since last update.

【CSS】インライン要素の行間を調整しながら、CSSでマーカーを引く

Last updated at Posted at 2020-07-08

linear-gradient を使って、マーカー風のCSSをつけることがよくあるのですが、インライン要素の場合、line-heightが効かずに戸惑うことがちょこちょこあったので、メモ。

親要素にline-heightを設定する

親要素に line-height を設定することで、小要素の line-height が設定できる様になります。

例:


<div class="parent">
  <p class="child">テキストテキストテキスト</p>
</div>

.parent {
  line-height: 1;
}

.parent .child {
  display: inline;
  line-height: 1.8; <- きく!
  background: linear-gradient(transparent 60%, #faaa1e 60%);
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0