typecho文章挂载bilibili视频响应式代码

效果

https://www.mosq.cn/post-389.html
hufengixaiwyud.png

方法

huafengxiayu165.png
打开bilibili的某个视频,然后如上图找到嵌入代码

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

复制嵌入代码添加到文章。
然后在给iframe 这个标签添加 class="iframe_video" iframe_video这个类名

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

之后就是添加样式css了

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
}

大功告成!
代码来自寒光博客

阿里云广告 淘宝优惠券
Last modification:October 29th, 2019 at 10:55 pm
If you think my article is useful to you, please feel free to appreciate

Leave a Comment

4 comments

  1. 灵曦

    滴!学生卡!打卡时间:下午6:23:24,请上车的乘客系好安全带~

  2. 242

    感谢分享咯咯咯

  3. repostone

    竟然看不懂。

  4. 森七

    滴!学生卡!打卡时间:下午10:55:46,请上车的乘客系好安全带~