步骤一:给主题的样式文件增加视频相关样式

/*视频挂载*/
.iframe_video {
    position: relative;
    width: 100%;
}

@media only screen and (max-width: 767px) {
    .iframe_video {
        height: 15em;
    }
}

@media only screen and (min-width: 768px) and (max-width: 991px) {
    .iframe_video {
        height: 20em;
    }
}

@media only screen and (min-width: 992px) and (max-width: 1199px) {
    .iframe_video {
        height: 30em;
    }
}

@media only screen and (min-width: 1200px) {
    .iframe_video {
        height: 40em;
    }
}

.iframe_cross {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 75%
}

.iframe_cross iframe {
    position: absolute;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0
}

这段代码的作用就是根据主题在不同设备打开,控制视频去适配大小。

步骤二:复制视频源代码

打开B站视频网页,如图找到嵌入代码然后复制到文章中,因为Typecho使用的是MarkDown编辑器,要在代码前后各加三个感叹号。

使用iframe格式的,可以用我的视频体验一下:

<iframe src="//player.bilibili.com/player.html?aid=716427270&bvid=BV14X4y1P7P8&cid=362291603&page=1" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"> </iframe>

复制适配后,把前面加的样式填进去

class="iframe_video"

填进去后是这样的:

<iframe src="//player.bilibili.com/player.html?aid=716427270&bvid=BV14X4y1P7P8&cid=362291603&page=1" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true" class="iframe_video> </iframe>
最后修改:2025 年 03 月 09 日
如果觉得我的文章对你有用,请随意赞赏