如何自定义字幕样式呢

CSS中有专门的伪元素 ::cue 可以控制字幕的样式。

可用的CSS属性包括:

  • color
  • opacity
  • visibility
  • text-decoration 和相关属性:text-decoration-line, text-decoration-color, text-decoration-style
  • text-shadow
  • background 和相关属性:background-color, background-clip, background-image, background-origin, background-position, background-repeat, background-size, background-attachment, background-blend-mode
  • outline 和相关属性:outline-color, outline-style, outline-width
  • font 和相关属性:font-kerning, font-style, font-variant, font-variant-numeric, font-variant-position, font-variant-east-asian (en-US), font-variant-caps, font-variant-alternates, font-variant-ligatures, font-synthesis, font-feature-settings, font-language-override, font-weight, font-size, font-size-adjust, font-stretch, font-family
  • line-height
  • white-space

Aliplayer字幕样式示例:

//无背景 白字 黑边 字体大小20px
.prism-player video::cue{
    background: none;
    color: #fff;
    text-shadow: 0 1px #000, 1px 0 #000, -1px 0 #000, 0 -1px #000;
    font-size: 20px;
}

将示例样式保存到 插件设置-Aliplayer播放器样式中即可,如下图: