开场
我们这里给你2种办法,一个是引用博主给的一个link标签来实现这个,另一个是自己加代码来实现这个。
Ⅰ:直接引用代码来实现
先说直接引用吧!
首先,你需要做的事情是,找到你的主题模板,或者是自己的网站的header.php
这个文件(或者是index.php
/index.html
),然后在head
这个标签里面加入下方的代码:
<link rel="stylesheet" href="https://api.beixibaobao.com/css/bilibili-player/bofangqi.css"
然后我们找到b站的分享按钮得到的代码:如下:
<iframe src="//player.bilibili.com/player.html?aid=74725430&cid=127822972&page=1" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"> </iframe>
我们将iframe
后面加上这个:class="iframe_video"
就变成了这样:
<iframe class="iframe_video" src="//player.bilibili.com/player.html?aid=74725430&cid=127822972&page=1" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"> </iframe>
然后就可以正常访问啦~(自动适配手机端的大小)
Ⅱ:把代码加载自己的网站来实现
请在主题的head
里面加入以下代码:
/*下方是视频挂载*/
.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站的分享按钮得到的代码:如下:
<iframe src="//player.bilibili.com/player.html?aid=74725430&cid=127822972&page=1" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"> </iframe>
我们将iframe
后面加上这个:class="iframe_video"
就变成了这样:
<iframe class="iframe_video" src="//player.bilibili.com/player.html?aid=74725430&cid=127822972&page=1" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true"> </iframe>
然后就可以正常访问啦~(自动适配手机端的大小)