商城排序实战案例(涉及AJAX,Jason,sort排序)

商城排序实战案例(涉及AJAX,Jason,sort排序)

,话不多说,我们先来介绍一下本次案例,商城排序是针对于深度解析Sort方法所进行的实际案例练习,其中利用Ajax请求数据,对json数据进行解析并渲染到浏览器上,案例实现了多种数据的交互排序,用简单的CSS制作了一个排序图标,图标会根据请求做出不同的响应动作。
,结构如下图所示,首先创建一个主文件夹,里面新建css img js json
等四个文件夹,其中除img文件夹里的随便找的图片外,其他文件我会以代码块的形式进行粘贴。
在这里插入图片描述

(1)css

// An highlighted block
html,body {
   
  width: 100%;
  height: 100%;
  background-color: #d0fadd2c;
}
#header {
   
 width: 1000px;
 height: 40px;
 line-height: 40px;
 margin: 30px auto;
 background: orange;
 box-sizing: border-box;
 font-size: 16px;
 padding: 0 10px;
 color: white;
 letter-spacing: 1px;
}
#header span {
   
  margin-right: 10px;
}
#header a {
   
  color: white;
  margin-right: 15px;
  position: relative;
}
#header a:hover {
   
  color: orangered;
}
#header a i {
   
  width: 0;
  height: 0;
  border:4px solid transparent;
  position: absolute;
}
#header a i.up {
   
  border-bottom-color: white;
  top:3px;
}
#header a i.down {
   
  border-top-color: white;
  top:15px;
}

#header a i.up.bg {
   
  border-bottom-color: red;
}
#header a i.down.bg {
   
  border-top-color: red;
}
/* 
=====================================
*/
#cardBox {
   
  width: 1000px;
  margin: 20px auto;
  display: flex;
  flex-wrap: wrap;
  
}
#cardBox li {
   
  width: 24%;
  box-sizing: border-box;
  padding: 10px;
  background: rgba(172, 255, 47, 0.336);
  margin: 0 .5% 10px .5%;
}

#cardBox li img {
   
  width: 100%;
  transition: all .2s;

}
#cardBox li img:hover {
   
  transform: scale(1.05);
}
#cardBox li span {
   
  display: block;
  margin-bottom: 5px;
  font-size: 18px;
  margin-left: 10px;
  color: orangered;
  transition: all .2s;
  cursor: pointer;
}
#cardBox li span:hover {
   
  text-shadow: 2px 2px 5px #000;

}


(2)json

// An highlighted block
[
  {
   
    "id": 1,
    "title": "HUAWEI全网通版(亮黑色)",
    "price": 499,
    "time": "2017-03-15",
    "hot": 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值