小辉网络社区致力于优质软件,活动线报,游戏辅助,绿色工具等资源共享,好货不私藏!

巧用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=&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>

温馨提示:如有转载或引用以上内容请将本文链接作为出处标注!百度已收录

免责声明:本站提供的一切软件、教程和内容信息仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑或手机中彻底删除上述内容。如果您喜欢该程序,请支持正版,购买注册,得到更好的正版服务。侵删请致信E-mail:431228450@qq.com

标签 暂无标签
资源分享
评论列表