WordPress 文章内嵌入 B 站视频自适应,在 B 站上打开需要引用的视频页面,在视频播放器下方找到【分享图标】—>【选择嵌入代码】—>【复制文本内容】。
方法一
在 WorePress 文章编辑中,选择【作为 HTML 编辑】,粘贴刚才复制的 B 站嵌入代码,在其<iframe src 元素标签中增加 class 属性,如:
- <iframe class="iframe_video"src="//player.bilibili.com/player.html?aid=243829823&bvid=BV1Sv411i7KS&cid=209606589&page=1&high_quality=1&danmaku=0" width="100%" height="100%" frameborder="no" scrolling="no" allowfullscreen="allowfullscreen"> </iframe>
之后在主题模板 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
- }
方法二
嵌入到 WordPress 文章中的 html 代码:
- <div class="smartideo">
- <div class="player">
- <iframe src="//player.bilibili.com/player.html?aid=243829823&bvid=BV1Sv411i7KS&cid=209606589&page=1&high_quality=1&danmaku=0" width="100%" height="100%" frameborder="no" scrolling="no" allowfullscreen="allowfullscreen"> </iframe>
- </div>
- </div>
放在 css 中的:
- .smartideo { z-index: 0; text-align: center; background: #CCC; line-height: 0; text-indent: 0; }
- .smartideo embed, .smartideo iframe { padding: 0; margin: 0; }
- .smartideo .player { width: 100%; height: 500px; overflow: hidden; position: relative; }
- .smartideo .player a.smartideo-play-link { display: block; width: 50px; height: 50px; text-decoration: none; border: 0; position: absolute; left: 50%; top: 50%; margin: -25px; }
- .smartideo .player a.smartideo-play-link p { display: none; }
- .smartideo .player .smartideo-play-button { width: 0; height: 0; border-top: 25px solid transparent; border-left: 50px solid #FFF; border-bottom: 25px solid transparent; }
- .smartideo .tips { background: #f2f2f2; text-align: center; max-height: 32px; line-height: 32px; font-size: 12px; }
- .smartideo .tips a { text-decoration: none; }
- @media screen and (max-width:959px){
- .smartideo .player { height: 450px; }
- }
- @media screen and (max-width:767px){
- .smartideo .player { height: 400px; }
- }
- @media screen and (max-width:639px){
- .smartideo .player { height: 350px; }
- }
- @media screen and (max-width:479px){
- .smartideo .player { height: 250px; }
- }
文章链接:https://www.wuyanshuo.cn/968.html
更新时间:2022年06月29日
本站资源均为两层压缩,第一层7z(后缀若为wys,请自行修改为7z)有解压密码;第二层zip或cbz,无解压密码,可直接使用漫画类软件程序查看;详情可参考解压教程。
本站大部分内容均收集于网络!若内容若侵犯到您的权益,请发送邮件至:service@wuyanshuo.cn我们将第一时间处理! 资源所需价格并非资源售卖价格,是收集、整理、编辑详情以及本站运营的适当补贴,并且本站不提供任何免费技术支持。 所有资源仅限于参考和学习,版权归原作者所有,更多请阅读无言说网络服务协议。