加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

html – 设计文字,使其出现在线上方(歌词上方的和弦)

发布时间:2020-12-14 18:51:40 所属栏目:资源 来源:网络整理
导读:我希望能够使用CSS在音乐中的歌词之上显示和弦.这就是我真的喜欢它的样子: C FThis line has a C chord,and it also has an F chord 使和弦变化显示在正确的地方.在HTML中,它看起来像这样: span class="chord"C/spanThis line has a C chord,and it also h
我希望能够使用CSS在音乐中的歌词之上显示和弦.这就是我真的喜欢它的样子:
C                                           F
This line has a C chord,and it also has an F chord

使和弦变化显示在正确的地方.在HTML中,它看起来像这样:

<span class="chord">C</span>This line has a C chord,and it also has an <span class="chord">F</span>F chord

我设法几乎得到了这种风格的效果:

.chord {
  position: relative;
  top: -1em;
}

但问题是它有差距:

C                                            F
 This line has a C chord,and it also has an  F chord

如果只有width:0(我将使用overflow:visible)工作在一个内联的跨度.有没有人有解决方案?

编辑:谢谢@Kyle Sevenoaks.对于任何有兴趣的人来说,这是我的完整的CSS,它允许经文标注< p>,和弦标记为< span>以及是否显示和弦是否与父div上的show-chords类切换:

p.song span {
  display: none;
}
p.song.show-chords p {
  line-height:2.3em;
  margin-bottom:2em;
}
p.song.show-chords span {
  position: relative;
  top: -1em;
  display:inline-block;
  width: 0;
  overflow:visible;
  text-shadow:#CCC -1px 1px;
  color:#00F;
  font-weight:bold;
  font-family:Arial,Helvetica,sans-serif;
}
<p class="song show-chords">
  <span class="chord">C</span>This line has a C chord,and it also has an <span class="chord">F</span>F chord
</p>

解决方法

对于内联元素,可以使用display:inline-block;让它接受宽度.但是对于你的问题,为什么不简单地添加左:3px; / * em或任何* /?它将缩进.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读