巧用iframe标签srcdoc属性制作点击加载调用代码
在页面使用iframe标签调用外部页面或视频等,会增加页面载入的时间,为了让iframe框架调用不影响页面加载速度,蓝叶分享下可以巧用iframe标签srcdoc属性制作点击加载调用的方法代码,让用户点击按钮加载框架,这样就不会影响到页面加载速度了,代码如下有需要的拿去使用吧。
//注意把页面网址跟图片网址替换修改成你自己的 <iframe width="600" height="360" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen srcdoc="<style>*{padding:0;margin:0;overflow:hidden}html,body{height:100%}span.icon-play{width: 60px;height:60px;display: inline-flex;align-items:center;justify-content:center;background:#037DD6;border-radius: 100%}img,span.overlay,vodep{position:absolute;width:100%;top:0;bottom:0;margin:auto;height:100%}span.overlay{text-align:center;font:48px/1.5 sans-serif;color:white;width: 100%;height: 100%;display: inline-flex;align-items: center;justify-content: center;background: rgba(0,0,0,0.5);transition: background 300ms ease;}span:hover{background: rgba(0,0,0,0.3)!important;}</style><a href=页面网址><img src=图片网址><span class="overlay"><span class="icon-play"><svg xmlns="http://www.w3.org/2000/svg" width="23" height="28" viewBox="0 0 23 28" fill="none">\n <path fill-rule="evenodd" clip-rule="evenodd" d="M0.976562 13.7469V25.0549C0.976562 26.6431 2.73876 27.5977 4.0691 26.7301L21.4079 15.4222C22.6178 14.6331 22.6178 12.8608 21.4079 12.0717L4.0691 0.763819C2.73876 -0.103793 0.976562 0.850786 0.976562 2.43904V13.7469Z" fill="white"/>\n </svg></span></span></a>"></iframe>
- 版权申明:此文如未标注转载均为本站原创,自由转载请表明出处《蓝叶》。
- 本文网址:https://lanye.org/web/1020.html
- 上篇文章:zblog蓝叶重复文章查重插件
- 下篇文章:2022年08月必应壁纸打包下载(电脑高清必应壁纸打包下载)