修改网站 添加自适应

以handsome主题为例 添加下面代码到 后台-开发者设置-自定义css

/*视频挂载*/
.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
}

获取cid和aid

Bilibili的APP分享出来的链接是这样的

https://www.bilibili.com/video/BV1CE411J77n/

而这条视频的直链是这样的

https://player.bilibili.com/player.html?aid=92687413&cid=158252438&page=1

在原来视频地址在'bilibili'前面加入一个i字符 获得cid和aid 复制就行了
https://www.ibilibili.com/video/BV1CE411J77n/

挂载

在合适的地方插入一下代码

<iframe class="iframe_video" src="//player.bilibili.com/player.html?aid=92687413&cid=158252438&page=1" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"> </iframe>

效果

最后修改:2022 年 04 月 18 日 12 : 31 PM
如果觉得我的文章对你有用,请随意赞赏
  • 本文作者:雨落倾城
  • 本文链接:https://yuluoqc.xyz/2022/04/18/780.html
  • 版权声明:本博客所有文章除特别声明外,均默认采用 CC BY-NC-SA 4.0 许可协议。
  • # 商业转载请联系作者获得授权,非商业转载请注明出处
    # 协议(License):署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)
    # For commercial use, please contact the author for authorization. For non-commercial use, please indicate the source.