首页 » 收集 » 正文内容
Typecho文章内挂载B站视频操作教程(附代码
寻梦xunm| 609| 收集
3年前
超过1105天 温馨提示
本文最后更新于2021年09月11日,已超过1105天没有更新,若内容或图片失效,请留言反馈。

昨天在B站投稿了一个Win11操作系统安装在WMware虚拟机的操作教程,顺便发到胖蒜网,并将视频挂载过来,发现不是很完美,就稍微调整了一下。

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

/*视频挂载*/
.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编辑器,要在代码前后各加三个感叹号。
3853091073.png
使用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>

发布文章,去打开文章看看,效果就跟我网站一样啦~~

文章来源于:https://pangsuan.com/p/iframe-video.html

0 赞 or 打赏
喜欢就打赏一点
微信 支付宝
隐私
Q Q:1340326824
邮箱:vipshiyi@qq.com
QQ群:422720328

我的音乐

微博客-专为自己编写开发的源码