<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>HTML on 阿珏酱のBlog</title>
    <link>https://zh.moejue.cn/categories/html/</link>
    <description>Recent content from 阿珏酱のBlog</description>
    <generator>Hugo</generator>
    <language>zh-cn</language>
    
    <managingEditor>xxx@example.com (MoeJue)</managingEditor>
    <webMaster>xxx@example.com (MoeJue)</webMaster>
    
    <copyright>本博客所有文章除特别声明外，均采用 BY-NC-SA 许可协议。转载请注明出处！</copyright>
    
    <lastBuildDate>Fri, 15 Aug 2025 06:15:23 +0000</lastBuildDate>
    
    
    <atom:link href="https://zh.moejue.cn/categories/html/index.xml" rel="self" type="application/rss&#43;xml" />
    

    
    

    <item>
      <title>论网速快慢的区别</title>
      <link>https://zh.moejue.cn/posts/119/</link>
      <pubDate>Sat, 07 Nov 2020 14:09:07 &#43;0000</pubDate>
      <author>xxx@example.com (MoeJue)</author>
      <guid>https://zh.moejue.cn/posts/119/</guid>
      <description>
        <![CDATA[<h1>论网速快慢的区别</h1><p>作者：MoeJue（xxx@example.com）</p>
        
          <p>论网速快慢的区别</p>
<p>随着网络的普及，用户对响应速度快慢越来越重视了，网站越快，用户的黏性和转化率也会越高。<br>
简单来说，就是要提高速度！影响网站速度的因素有很多，比如&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;.</p>
<p>一本正经可不是我的风格，下面请看我的表演<br>
<strong>想法起源</strong>：<br>
<img src="https://gh-proxy.com/github.com/iAJue/MoeJueBlogPic/blob/master/Images/2020/11/07/0072Vf1ply1gkgf5kosbfj30bl0l4mzm.jpg" alt=""><br>
一开始的想法是使用纯css进行实现，把底图base64编码后直接放在background-image上，就可以达到背景图片于网页一同加载出来的效果</p>
<p>第一步：<br>
首先将提前准备好的素材图片进行处理，拔下泳衣和泳裙 <img src="https://gh-proxy.com/github.com/iAJue/MoeJueBlogPic/blob/master/Images/2020/11/07/0072Vf1ply1gkgfdqj354j302s033dfn.jpg" alt=""><br>
<img src="https://gh-proxy.com/github.com/iAJue/MoeJueBlogPic/blob/master/Images/2020/11/07/0072Vf1ply1gkgf79od99j31fv0m47wh.jpg" alt=""><br>
第二步：<br>
新建个HTML文件<br>
<img src="https://gh-proxy.com/github.com/iAJue/MoeJueBlogPic/blob/master/Images/2020/11/07/0072Vf1ply1gkgf9om2ylj30b306q3zf.jpg" alt=""><br>
第三步：</p>
<div class="裸体">
        <div class="泳衣" id="泳衣"></div>
        <div class="泳裙" id="泳裙"></div>
</div>
<p>完成。。<br>
然后就发现个问题，由于我的底图文件大小达到了12兆，编码后的字符串过大，导致网页加载又卡又慢，实在无用户体验<br>
而且这种方式加载的底图会突然的显示出来，过于唐突，效果不好</p>
<p>后改用：<br>
css+JavaScript进行实现，由background-image直接加载背景图片，能达到逐渐显示的效果，待底图加载完毕后再由js动态插入配图</p>
<p>window.onload = function(){
var img=new Image();
img.src=&lsquo;裸体.jpg&rsquo;;
if(img.width==0){
alert(&lsquo;图片加载失败&rsquo;)
}else{
document.getElementById(&ldquo;泳衣&rdquo;).style.backgroundImage=&ldquo;url(泳衣.png)&rdquo;;
document.getElementById(&ldquo;泳裙&rdquo;).style.backgroundImage=&ldquo;url(泳裙.png)&rdquo;;
}
}</p>
<p>不禁感慨一句，什么破网络，慢的连人物图片的衣服都加载不出来</p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/dynKiyrFtak?si=6UFLhBK7VMgbLWPE" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen=""></iframe>
        
        <hr><p>本文2020-11-07首发于<a href='https://zh.moejue.cn/'>阿珏酱のBlog</a>，最后修改于2025-08-15</p>]]>
      </description>
      
        <category>HTML</category>
      
    </item>
    
    

    <item>
      <title>HTML5画布-小球碰撞</title>
      <link>https://zh.moejue.cn/posts/41/</link>
      <pubDate>Tue, 18 Jul 2017 09:17:31 &#43;0000</pubDate>
      <author>xxx@example.com (MoeJue)</author>
      <guid>https://zh.moejue.cn/posts/41/</guid>
      <description>
        <![CDATA[<h1>HTML5画布-小球碰撞</h1><p>作者：MoeJue（xxx@example.com）</p>
        
          <p>html5是万维网的核心语言、标准通用标记语言下的一个应用超文本标记语言（HTML）的第五次重大修改。<br>
自1999年以后HTML 4.01 已经改变了很多，今天，在HTML 4.01中的几个已经被废弃，这些元素在HTML5中已经被删除或重新定义。为了更好地处理今天的互联网应用，HTML5添加了很多新元素及功能，比如： 图形的绘制，多媒体内容，更好的页面结构，更好的形式 处理，和几个api拖放元素，定位，包括网页 应用程序缓存，存储，网络工作者，等。</p>
<p>标签</p>
<p>描述</p>
<canvas>
<p>标签定义图形，比如图表和其他图像。该标签基于 JavaScript 的绘图 API</p>
<p>效果展示：</p>
<p>你的浏览器不支持H5</p>
<p>代码部分：</p>
<canvas id="my-canvas" width="500px" height="400px" style="border:1px solid red" >
你的浏览器不支持H5</canvas>
<script type="text/javascript">
	<!-- 得到画布对象 -->
	var my\_canvas = document.getElementById("my-canvas");
	<!-- 得到画笔 -->
	var my\_huabi = my\_canvas.getContext("2d");
	var x = 50;
	var y = 50;
	var r = 20;
	function deawBall(x,y){
		<!-- 设置画笔颜色 -->
		my\_huabi.fillStyle = "green";
		<!-- 开始一个新路径 -->
		my\_huabi.beginPath();
		<!-- 画出小球 -->
		my\_huabi.arc(x, y, r, 0, 2 \* Math.PI);
		<!-- 关闭路径 -->
		my\_huabi.fill();
	}
	var fx\_x = true;//当fx\_x为true时，向x轴移动
	var fx\_y = true;//当fx\_y为true时，向y轴移动
	var speen = 1;
	<!-- 定时器 -->
	window.setInterval("moveBall()", 10);
	function moveBall(){
		<!-- 判断当前小球的运动方向 -->
		if(fx\_x == true){
			x += speen;
			if(x >= 500-r){
				<!-- 当达到底部时，向上弹 -->
				fx\_x = false;
			}
		}else{
			x -= speen;
			if(x <= 0+r){
				<!-- 当达到顶部时，向下弹 -->
				fx\_x = true;
			}
		}
		if(fx\_y == true){
			y += speen;
			if(y >= 400-r){
				<!-- 当达到左侧时，向右侧弹 -->
				fx\_y = false;
			}
		}else{
			y -= speen;
			if(y <= 0+r){
				<!-- 当达到右侧时，向左侧弹 -->
				fx\_y = true;
			}
		}
		<!-- 清除画布 重画 -->
		my\_huabi.clearRect(0, 0, 500, 400);
		deawBall(x, y);
	}
</script>
<!-- 得到画布对象 --> var my\_canvas = document.getElementById("my-canvas"); <!-- 得到画笔 --> var my\_huabi = my\_canvas.getContext("2d"); var x = 50; var y = 50; var r = 20; function deawBall(x,y){ <!-- 设置画笔颜色 --> my\_huabi.fillStyle = "green"; <!-- 开始一个新路径 --> my\_huabi.beginPath(); <!-- 画出小球 --> my\_huabi.arc(x, y, r, 0, 2 \* Math.PI); <!-- 关闭路径 --> my\_huabi.fill(); } var fx\_x = true;//当fx\_x为true时，向x轴移动 var fx\_y = true;//当fx\_y为true时，向y轴移动 var speen = 1; <!-- 定时器 --> window.setInterval("moveBall()", 10); function moveBall(){ <!-- 判断当前小球的运动方向 --> if(fx\_x == true){ x += speen; if(x >= 500-r){ <!-- 当达到底部时，向上弹 --> fx\_x = false; } }else{ x -= speen; if(x <= 0+r){ <!-- 当达到顶部时，向下弹 --> fx\_x = true; } } if(fx\_y == true){ y += speen; if(y >= 400-r){ <!-- 当达到左侧时，向右侧弹 --> fx\_y = false; } }else{ y -= speen; if(y <= 0+r){ <!-- 当达到右侧时，向左侧弹 --> fx\_y = true; } } <!-- 清除画布 重画 --> my\_huabi.clearRect(0, 0, 500, 400); deawBall(x, y); }
        
        <hr><p>本文2017-07-18首发于<a href='https://zh.moejue.cn/'>阿珏酱のBlog</a>，最后修改于2017-07-18</p>]]>
      </description>
      
        <category>HTML</category>
      
    </item>
    
  </channel>
</rss>
