分享模板插件精品好资源
现在位置:首页 > 网站设计 > 巧用iframe标签srcdoc属性制作点击加载调用代码

巧用iframe标签srcdoc属性制作点击加载调用代码

作者:蓝叶 分类:网站设计 时间:2022-09-08 浏览:791

在页面使用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=&quot;overlay&quot;><span class=&quot;icon-play&quot;><svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;23&quot; height=&quot;28&quot; viewBox=&quot;0 0 23 28&quot; fill=&quot;none&quot;>\n        <path fill-rule=&quot;evenodd&quot; clip-rule=&quot;evenodd&quot; d=&quot;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&quot; fill=&quot;white&quot;/>\n        </svg></span></span></a>"></iframe>

免责声明:

本页网址:点击复制分享给朋友吧!

本站分享的一切内容资源如若没有备注,均为蓝叶原创,如需转载请注明出处;如有侵权请与我们联系处理。敬请谅解!

评论列表
挤眼亲亲咆哮开心想想可怜糗大了委屈哈哈小声点右哼哼左哼哼疑问坏笑赚钱啦悲伤耍酷勾引厉害握手耶嘻嘻害羞鼓掌馋嘴抓狂抱抱围观威武给力
提交评论

清空信息
关闭评论