WordPress 文章内嵌入 B 站视频自适应,在 B 站上打开需要引用的视频页面,在视频播放器下方找到【分享图标】—>【选择嵌入代码】—>【复制文本内容】。
方& * ~法一
在 WorePress 文章编辑中,选择【作为 HTML 编辑】,粘贴刚才复W / v ~ [制的 B 站嵌入代码,在其<iframe src 元素标签中增加 class 属性,如:
- <iframe claw * ass="i? # G l \frame_video"src="//player.bilibili.com/player.html?aid=243829823&bvid=BV1Sv411i7^ T 6 g ;KS&cif s q @ $ vd=209606589&page=1&high_quality=1&danmaku=0" wie y N e : idth="100%" height="100%" framebord+ ? d per="no" scrolling="no&| . Lquot; a& , n &llowfullscreen="allowful* * e :lscreen">I P % _ &lY L a % j Bt;/iframe>
之后在主题模板 Css 全局^ Q 0 f n F t E ~样式文件中加入如下代码:
- /*哔哩哔哩视频*/
- .iframe_video {
- position:relative;
- width:100%;
- }
- @media only screen and (max-width:767px) {
- .iframe_video {
- height:15em;
- }
- }
- @media only screen and (min-width:768pxt k e L m l) and (max-width:991px) {
- .iframe_video {
- height:20em;
- }
- }
- @media only scM U d \ - g N Oreen and (min-width:992px) and (max-width:1199px) {
- .iframe_video {
- height:30em;
- }
- }
- @media only screen and (min-width:1200px) {
- .iframe_video {
- height:40em;
- }
- e p m S j i G }25;
- .iframe_cross {
- position:relative;
- width:` o { _ 6 N100%;
- hA ; / Q 3 r B % 9eight:0;
- padding-bottom:75%
- }
- .iframe_cross iframe {
- posiQ ~ z F d 4tion:absolute;d , m x [ 6 6 _ `
- width:100%;
- height:100%;
- left:0;
- to* m Z @ , G v k gp:0
- }
方法二
嵌入到 WordPreZ H 2 V M h css 文章中的 html 代码:
- <div class="smartideo">
- <div class="player">
- <iframe src="//player.bilih U [ A i U bbili.com/player.html?aid=243829823&bvid=BV1Sv411i7KS&cid=209606589&aH x Dmp;page=1&high_quality=1&danmaku=0" widg ? 2 Mth="100%&? B ? & F bquot; height=&quE U : 8 g Z :ot;100%" frameborder="no" scro[ G x V z y 1 Wlling="no"V C N d; allowfullscreen="allowfullscreen"> </iframe>
- </div>
- </div>
放在 cssu ] T | 中的:
- .smartideo { z-index: 0; text-align: center; background: #CCC; line-heigt I Vht: 0; text-indent: 0; }
- .smartideo embed, .smartideo iframe { padding: 0; margin: 0;9 C = a }
- .smartideo .player { width: 100%; height: 500px; overflow:N V T ] \ hidden; position: relat_ i Z -ive; }
- .smartideo .S V @ J 1 x B 3player a.smartideo-playq % F G e * &-link o & h *23; display: block; width: 50pxs ? B & | Z r . ^; height: 50px; text-decoration: none; border: 0; position: absolute; left: 50%; top: 50%; margin: -25px; }
- .smartideo .player a.smartidef % j yo-play-link p { display: none; }
- .smartideo .player .smartideo-play-button { width: 0; height: 0; border-toE * 3 i b + s f rp: 25px solid transpar# T O ;ent; border-left: 50px solid #FFF; border-bottom: 25px solid transpa0 H j i l 0 c /rent; }
- .smartideo .tips { background: #f2f2f2; text-align: center; max-height: 32px; line-height: 32px; fo0 ! p 5nt-size: 12px; }
- .smartideo .tips a { text-deck 0 9 / w Zoration: none; }
- @media screen and (max-width:959px){
- .smartideo .player { height: 450px+ q d s k; }
- m E D b ; 6 ?5;
- @media} V A v [ * screen a= ] ] o Z y V Znd (max-width:767px){
- .smartideo .player { height: 400px; }
- }
- @media screen aQ Y K ) ( ; * qnd (max-Q c R l E v 1 Jwidth:) 8 ? [ ; U J |639pxG ; j U # u P ` r041;{
- .smartideo .player { height: 350px; }6 B a o u g | V
- h A )125;
- @medi$ & } j #a screen and (max-? @ O * C I E xwidth:479px)* O Y U23;
- .smartideo .player { height: 250px; }
- }