博客列表 >web页集合弹性盒子,精灵图,flex布局,grid布局实现移动端首页

web页集合弹性盒子,精灵图,flex布局,grid布局实现移动端首页

零龙
零龙原创
2020年07月03日 23:46:13734浏览

web页集合弹性盒子,精灵图,flex布局,grid布局实现移动端首页


源码:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <link rel="stylesheet" href="font/iconfont.css" />
  7. <title>移动端首页</title>
  8. </head>
  9. <script src="js/loading.js"></script>
  10. <style>
  11. * {
  12. margin: 0;
  13. padding: 0;
  14. box-sizing: border-box;
  15. font-size: 15px;
  16. }
  17. a {
  18. text-decoration: none;
  19. color: rgb(173, 208, 255);
  20. }
  21. body {
  22. background: #eee;
  23. width: 100%;
  24. max-width: 10rem;
  25. position: relative;
  26. margin: 0 auto;
  27. }
  28. header {
  29. height: 0.8rem;
  30. display: -webkit-box;
  31. display: -moz-box;
  32. padding: 0.2;
  33. position: relative;
  34. background: rgb(255, 255, 255);
  35. display: flex;
  36. flex-flow: row nowrap;
  37. text-align: center;
  38. }
  39. header a:first-of-type {
  40. width: 2rem;
  41. line-height: 0.8rem;
  42. display: block;
  43. -moz-box-flex: 0;
  44. position: relative;
  45. color: green;
  46. }
  47. header a:first-of-type span {
  48. font-size: 0.3rem;
  49. }
  50. header a:nth-of-type(2) {
  51. width: 7.4rem;
  52. line-height: 0.8rem;
  53. }
  54. header a:nth-of-type(2) input {
  55. width: 6.5rem;
  56. height: 0.6rem;
  57. background: #f2f2f2;
  58. border-radius: 0.1rem;
  59. border: 0rem;
  60. padding-left: 0.1rem;
  61. color: #666;
  62. font-size: 0.25rem;
  63. }
  64. header a:nth-of-type(2) button {
  65. background: #f2f2f2;
  66. height: 0.6rem;
  67. border-radius: 0.1rem;
  68. position: relative;
  69. right: 0.5rem;
  70. border: 0rem;
  71. }
  72. header a:last-of-type {
  73. width: 1rem;
  74. }
  75. header a:last-of-type span {
  76. font-size: 0.5rem;
  77. line-height: 0.8rem;
  78. -webkit-font-size: 0.6rem;
  79. }
  80. .top {
  81. width: 100%;
  82. max-width: 10rem;
  83. background: url("http://www.situcms.com/uploads/2018/1023/a65fb1e2acaa597e80e6fd753e4363b4.jpg")
  84. no-repeat;
  85. background-size:10rem 3.6rem ;
  86. height: 3.6rem;
  87. }
  88. .nav {
  89. width: 100%;
  90. max-width: 10rem;
  91. height: 3.5rem;
  92. background: #fff;
  93. padding: 0.3rem;
  94. margin-top: 0.01rem;
  95. }
  96. .nav > ul {
  97. max-width: 10rem;
  98. list-style: none;
  99. display: flex;
  100. justify-content: space-evenly;
  101. flex-flow: row wrap;
  102. text-align: center;
  103. }
  104. .nav > ul > li {
  105. width: 1.8rem;
  106. height: 1.5rem;
  107. }
  108. .nav > ul > li:first-of-type > span {
  109. background: url("image/tb.png") no-repeat;
  110. background-size: 0.75rem 7rem;
  111. background-position: -2px -37px;
  112. width: 0.7rem;
  113. height: 0.7rem;
  114. display: inline-block;
  115. }
  116. .nav > ul > li:nth-of-type(2) > span {
  117. background: url("image/tb.png") no-repeat;
  118. background-size: 0.75rem 7rem;
  119. background-position: -2px 1px;
  120. width: 0.7rem;
  121. height: 0.7rem;
  122. display: inline-block;
  123. }
  124. .nav > ul > li:nth-of-type(3) > span {
  125. background: url("image/tb.png") no-repeat;
  126. background-size: 0.75rem 7rem;
  127. background-position: -2px -76px;
  128. width: 0.7rem;
  129. height: 0.7rem;
  130. display: inline-block;
  131. }
  132. .nav > ul > li:nth-of-type(4) > span {
  133. background: url("image/tb.png") no-repeat;
  134. background-size: 0.75rem 7rem;
  135. background-position: -2px -114px;
  136. width: 0.7rem;
  137. height: 0.7rem;
  138. display: inline-block;
  139. }
  140. .nav > ul > li:nth-of-type(5) > span {
  141. background: url("image/tb.png") no-repeat;
  142. background-size: 0.75rem 7rem;
  143. background-position: -2px -152px;
  144. width: 0.7rem;
  145. height: 0.7rem;
  146. display: inline-block;
  147. }
  148. .nav > ul > li:nth-of-type(6) > span {
  149. background: url("image/tb.png") no-repeat;
  150. background-size: 0.75rem 7rem;
  151. background-position: -2px -191px;
  152. width: 0.7rem;
  153. height: 0.7rem;
  154. display: inline-block;
  155. }
  156. .nav > ul > li:nth-of-type(7) > span {
  157. background: url("image/tb.png") no-repeat;
  158. background-size: 0.75rem 7rem;
  159. background-position: -2px -229px;
  160. width: 0.7rem;
  161. height: 0.7rem;
  162. display: inline-block;
  163. }
  164. .nav > ul > li:nth-of-type(8) > span {
  165. background: url("image/tb.png") no-repeat;
  166. background-size: 0.75rem 7rem;
  167. background-position: -2px -268px;
  168. width: 0.7rem;
  169. height: 0.7rem;
  170. display: inline-block;
  171. }
  172. .nav > ul > li:nth-of-type(9) > span {
  173. background: url("image/tb.png") no-repeat;
  174. background-size: 0.75rem 7rem;
  175. background-position: -2px -306px;
  176. width: 0.7rem;
  177. height: 0.7rem;
  178. display: inline-block;
  179. }
  180. .nav > ul > li:last-of-type > span {
  181. background: url("image/tb.png") no-repeat;
  182. background-size: 0.75rem 7rem;
  183. background-position: -2px -344px;
  184. width: 0.7rem;
  185. height: 0.7rem;
  186. display: inline-block;
  187. }
  188. .nav > ul > li > a {
  189. float: left;
  190. width: 100%;
  191. font-size: 0.3rem;
  192. color: #666;
  193. }
  194. .container{
  195. width: 100%;
  196. height: 4.8rem;
  197. margin-top: 0.01rem;
  198. background: #fff;
  199. display: grid;
  200. grid-template-columns:4rem 5.7rem;
  201. grid-template-rows:2.2rem 2.2rem;
  202. place-items:center;
  203. gap:0.1rem;
  204. padding: 0.1rem;
  205. }
  206. .container a:first-of-type{
  207. background:url("http://www.situcms.com/uploads/2018/1023/b66a15f2b65535057b87d60455544890.jpg");
  208. background-size: 4rem 2.2rem;
  209. width: 4rem;
  210. height: 2.2rem;
  211. }
  212. .container a:hover{
  213. box-shadow: 0px 0px 0.1rem rgba(53, 53, 53, 0.712);
  214. }
  215. .container a:nth-of-type(2){
  216. background: #666;
  217. grid-row: span 2;
  218. background: url("image/timg.jpg");
  219. background-size: 5.6rem 4.5rem;
  220. width: 5.6rem;
  221. height: 4.5rem;
  222. }
  223. .container a:nth-of-type(3){
  224. background:url("image/0.jpg");
  225. background-size: 4rem 2.2rem;
  226. width: 4rem;
  227. height: 2.2rem;
  228. }
  229. .c-nav{
  230. width: 100%;
  231. height: 5rem;
  232. background: #fff;
  233. margin-top: 0.01rem;
  234. }
  235. .c-nav ul{
  236. list-style: none;
  237. display: grid;
  238. grid-template-columns:repeat(3,3rem) ;
  239. grid-template-rows:repeat(5,1rem);
  240. place-content: center;
  241. text-align: center;
  242. }
  243. .c-nav ul li{
  244. color: #666;
  245. }
  246. .c-nav ul li:first-of-type{
  247. grid-column:span 3;
  248. line-height: 0.8rem;
  249. font-size: 0.33rem;
  250. }
  251. .c-nav ul li:first-of-type i{
  252. margin-left: 0.1rem;
  253. margin-right: 0.1rem;
  254. line-height: 1.1rem;
  255. color:#999;
  256. }
  257. .c-nav ul li a{
  258. border: 1px solid #ccc;
  259. line-height: 0.7rem;
  260. color:#999;
  261. width: 2.5rem;
  262. height: 0.7rem;
  263. display:inline-block;
  264. margin-top: 0.05rem;
  265. }
  266. .c-nav ul li a:hover{
  267. box-shadow: 0rem 0rem 0.05rem rgba(53, 53, 53, 0.712);
  268. }
  269. .c-nav ul li:last-of-type{
  270. grid-column: span 3;
  271. line-height: 0.8rem;
  272. font-size: 0.33rem;
  273. border-top: 0.01rem solid #ccc;
  274. }
  275. .c-nav ul li:last-of-type a{
  276. border: 0;
  277. color:yellowgreen;
  278. }
  279. .c-nav ul li:last-of-type a:hover{
  280. box-shadow:0 0 0;
  281. }
  282. .c-nav ul li:last-of-type a span{
  283. font-size: 0.2rem;
  284. margin-left: 0.1rem;
  285. }
  286. .c-r{
  287. width: 100%;
  288. margin-top: 0.05rem;
  289. background: #fff;
  290. }
  291. .c-r .c-rt{
  292. height: 0.8rem;
  293. line-height: 0.8rem;
  294. color: red;
  295. padding-left: 0.3rem;
  296. font-size: 0.3rem;
  297. }
  298. .c-r > .c-rc{
  299. padding: 0.1rem;
  300. width: 90%;
  301. margin: 0 auto;
  302. position: relative;
  303. }
  304. .c-rc > .c-rc1{
  305. background-image: linear-gradient(0deg, #eee, #fff);
  306. height: 3.5rem;
  307. text-align: center;
  308. padding: 0.2rem;
  309. }
  310. .c-rc >.c-rc1 > img{
  311. border: 0rem;
  312. width: 7rem;
  313. display:inline-block;
  314. }
  315. .c-rc > .c-rc2{
  316. height: 0.8rem;
  317. line-height: 0.8rem;
  318. color:#fff;
  319. padding-left: 0.3rem;
  320. font-size: 0.3rem;
  321. width:98%;
  322. position: absolute;
  323. top:2.5rem;
  324. background: rgba(34, 34, 34, 0.363);
  325. }
  326. .c-rc > .c-rc2 a{
  327. color: #fff;
  328. }
  329. .c-rc3{
  330. width: 100%;
  331. height: 2rem;
  332. list-style: none;
  333. margin-top: 0.2rem;
  334. }
  335. .c-rc3 a{
  336. width: 4rem;
  337. height: 2rem;
  338. float: left;
  339. margin: 0.1rem;
  340. margin-bottom: 1rem;
  341. }
  342. .c-rc3 a img{
  343. width: 4rem;
  344. height: 2.3rem;
  345. border-radius: 0.2rem;
  346. box-shadow: 0 0 0.3rem rgba(53, 53, 53, 0.11);
  347. }
  348. .c-rc3 a span{
  349. float: left;
  350. white-space:nowrap;
  351. text-overflow: ellipsis;
  352. overflow: hidden;
  353. width: 4rem;
  354. }
  355. .c-rf{
  356. width: 100%;
  357. background: #fff;
  358. height: 1rem;
  359. line-height: 1rem;
  360. text-align:center ;
  361. overflow: hidden;
  362. border-top: 0.01rem solid #eee;
  363. }
  364. .c-rf a{
  365. color: goldenrod;
  366. }
  367. .c-rf span{
  368. font-size: 0.2rem;
  369. }
  370. .c-f{
  371. height: 1rem;
  372. background: #fff;
  373. margin-top: 0.01rem;
  374. }
  375. .c-f ul{
  376. list-style: none;
  377. }
  378. .c-f ul li{
  379. width: 3rem;
  380. text-align: center;
  381. line-height: 1rem;
  382. float: left;
  383. }
  384. .c-f ul li a{
  385. color:green;
  386. font-size: 0.33rem;
  387. }
  388. .c-f ul li:hover{
  389. border-bottom: 0.05rem solid green;
  390. }
  391. .c-fc{
  392. width: 100%;
  393. float:left ;
  394. position: relative;
  395. }
  396. .c-fc1{
  397. width: 100%;
  398. height: 4.5rem;
  399. background: #ccc;
  400. padding: 0.5rem;
  401. text-align: center;
  402. }
  403. .c-fc1 i{
  404. position: absolute;
  405. background: rgba(0, 0, 0, 0.521);
  406. width: 1.8rem;
  407. height: 0.5rem;
  408. top:0.3rem;
  409. left: 1rem;
  410. border-radius: 0.3rem;
  411. text-align: left;
  412. padding-left: 0.15rem;
  413. line-height: 0.5rem;
  414. color: #fff;
  415. font-style: normal;
  416. }
  417. .c-fc1 strong{
  418. position: absolute;
  419. background:red;
  420. top:3.5rem;
  421. left: 0;
  422. width: 1.5rem;
  423. height: 0.8rem;
  424. border-radius: 0 0.15rem 0.15rem 0;
  425. font-size: 0.35rem;
  426. line-height: 0.8rem;
  427. color: lawngreen;
  428. font-weight: normal;
  429. }
  430. .c-fc2{
  431. width: 100%;
  432. height: 1.6rem;
  433. background: #fff;
  434. padding: 0.1rem;
  435. white-space:nowrap;
  436. text-overflow: ellipsis;
  437. overflow: hidden;
  438. text-align: left;
  439. }
  440. .c-fc21{
  441. width: 100%;
  442. font-size: 0.3rem;
  443. }
  444. .c-fc2 p{
  445. font-size: 0.4rem;
  446. color: #000;
  447. width: 100%;
  448. }
  449. .c-fc2 b{
  450. width: 100%;
  451. text-align:left;
  452. color:steelblue;
  453. font-size: 0.24rem;
  454. font-weight: normal;
  455. }
  456. .c-fc2 i{
  457. border: 0.01rem solid green;
  458. font-size: 0.22rem;
  459. color:tomato;
  460. padding: 0.05rem;
  461. float: left;
  462. font-style: normal;
  463. line-height: 0.20rem;
  464. border-radius: 0.08rem;
  465. margin-right: 0.05rem;
  466. margin-top: 0.05rem;
  467. }
  468. .foot{
  469. width: 100%;
  470. height: 2.3rem;
  471. margin-top: 0.05rem;
  472. background-color: #fff;
  473. display: flex;
  474. flex-flow: row nowrap;
  475. justify-content: space-around;
  476. text-align: center;
  477. }
  478. .foot a{
  479. width: 2rem;
  480. height: 1.6rem;
  481. margin-top: 0.5rem;
  482. }
  483. .foot a span{
  484. font-size: 1.2rem;
  485. color: #ccc;
  486. font-weight: normal;
  487. }
  488. .foot a i{
  489. font-size: 0.3rem;
  490. color: #ccc;
  491. text-align: center;
  492. float: left;
  493. font-style: normal;
  494. width: 2rem;
  495. }
  496. </style>
  497. <body>
  498. <header>
  499. <a href="">选择城市<span class="iconfont icon-arrow-right"></span></a>
  500. <a>
  501. <form action="#" method="GET" name="form">
  502. <input
  503. type="text"
  504. id="myinput"
  505. name="myinput"
  506. class="search-text"
  507. placeholder="搜索目的地/关键词"
  508. />
  509. <button class="iconfont icon-sousuo"></button>
  510. </form>
  511. </a>
  512. <a href="#"><span class="iconfont icon-touxiang"></span></a>
  513. </header>
  514. <div class="top"></div>
  515. <div class="nav">
  516. <ul>
  517. <li><span></span><a href="">结伴</a></li>
  518. <li><span></span><a href="">景点</a></li>
  519. <li><span></span><a href="">路线</a></li>
  520. <li><span></span><a href="">导游</a></li>
  521. <li><span></span><a href="">酒店</a></li>
  522. <li><span></span><a href="">特产</a></li>
  523. <li><span></span><a href="">租车</a></li>
  524. <li><span></span><a href="">游轮</a></li>
  525. <li><span></span><a href="">签证</a></li>
  526. <li><span></span><a href="">户外</a></li>
  527. </ul>
  528. </div>
  529. <div class="container">
  530. <a href=""></a>
  531. <a href=""></a>
  532. <a href=""></a>
  533. </div>
  534. <div class="c-nav">
  535. <ul>
  536. <li><i>——</i>推荐目的地<i>——</i></li>
  537. <li><a href="">国内旅游</a></li>
  538. <li><a href="">拉萨</a></li>
  539. <li><a href="">日本</a></li>
  540. <li><a href="">峨眉山</a></li>
  541. <li><a href="">九寨沟</a></li>
  542. <li><a href="">首尔</a></li>
  543. <li><a href="">普吉岛</a></li>
  544. <li><a href="">马尔代夫</a></li>
  545. <li><a href="">港澳台</a></li>
  546. <li><a href="">目的地大全<span class="iconfont icon-arrow-right"></span></a></li>
  547. </ul>
  548. </div>
  549. <div class="c-r">
  550. <div class="c-rt">热卖景区</div>
  551. <div class="c-rc">
  552. <div class="c-rc1">
  553. <img src="http://www.situcms.com/uploads/2018/1023/a59771d3aec6b4ac76d319ed6dcf91c2_350x150.png">
  554. </div>
  555. <div class="c-rc2">
  556. <a href="">马尔代夫多少钱?</a>
  557. </div>
  558. <div class="c-rc3">
  559. <a href=""><img src="http://www.situcms.com/uploads/2015/1028/14630bcd06ba3ff7ed8b82c624801460_170x85.jpg" >
  560. <span>泰、老、越三国有望实现单一旅游签证</span>
  561. </a>
  562. <a href=""><img src="http://www.situcms.com/uploads/2018/0515/44239935fcfae2520dbab338a23ca5ec_170x85.jpg" alt="">
  563. <span>新马泰旅游签证怎么办理?</span>
  564. </a>
  565. </div>
  566. </div>
  567. <div class="c-rf">
  568. <a href="">查看更多<span class="iconfont icon-arrow-right"></span></a>
  569. </div>
  570. </div>
  571. <div class="c-f">
  572. <div class="c-ft">
  573. <ul>
  574. <li><a href="">热门旅游路线</a>
  575. </li>
  576. <li><a href="">热门酒店预订</a>
  577. </li>
  578. <li><a href="">热门租车</a>
  579. </li>
  580. </ul>
  581. </div>
  582. <div class="c-fc">
  583. <a href="">
  584. <div class="c-fc1">
  585. <img src="http://www.situcms.com/uploads/2017/1020/d9616c1cb0d89689a19c2aa897d9dc81_375x187.png" alt="">
  586. <i><span class="iconfont icon-dingwei"></span>&nbsp;昆明出发</i>
  587. <strong>¥:6500</strong>
  588. </div>
  589. <div class="c-fc2">
  590. <p>九寨沟+黄龙+卧龙熊猫谷+都江堰双汽4日跟团游</p>
  591. <b>行程内用车为旅游交通巴士,散客拼团全程可能非同一台车;因延线有行车公里数限制或部分路段维修,易发生堵车,发车时间均较早,行程
  592. </b>
  593. <i>九寨沟</i>
  594. <i>省心更团游</i>
  595. <i>飞机团</i>
  596. <i>汽车团</i>
  597. <i>快乐自助游</i>
  598. </div>
  599. </a>
  600. </ul>
  601. </div>
  602. <div class="c-fc">
  603. <a href="">
  604. <div class="c-fc1">
  605. <img src="http://www.situcms.com/uploads/2017/0428/1d48604ef1bb654e44ad9a1217b03f6a_375x187.jpg" alt="">
  606. <i><span class="iconfont icon-dingwei"></span>&nbsp;昆明出发</i>
  607. <strong>¥:2500</strong>
  608. </div>
  609. <div class="c-fc2">
  610. <p>云南昆明+大理+丽江+洱海+玉龙雪山6日5晚跟团游 </p>
  611. <b>行程内用车为旅游交通巴士,散客拼团全程可能非同一台车;因延线有行车公里数限制或部分路段维修,易发生堵车,发车时间均较早,行程
  612. </b>
  613. <i>九寨沟</i>
  614. <i>省心更团游</i>
  615. <i>飞机团</i>
  616. <i>汽车团</i>
  617. <i>快乐自助游</i>
  618. </div>
  619. </a>
  620. </ul>
  621. </div>
  622. <div class="c-fc">
  623. <a href="">
  624. <div class="c-fc1">
  625. <img src="http://www.situcms.com/uploads/main/litimg/20150722/20150722154931_375x187.png" alt="">
  626. <i><span class="iconfont icon-dingwei"></span>&nbsp;昆明出发</i>
  627. <strong>¥:500</strong>
  628. </div>
  629. <div class="c-fc2">
  630. <p>厦门+鼓浪屿+福建土楼5日4晚跟团游 3晚威斯汀+5星下午茶 1晚岛上 </p>
  631. <b>行程内用车为旅游交通巴士,散客拼团全程可能非同一台车;因延线有行车公里数限制或部分路段维修,易发生堵车,发车时间均较早,行程
  632. </b>
  633. <i>九寨沟</i>
  634. <i>省心更团游</i>
  635. <i>飞机团</i>
  636. <i>汽车团</i>
  637. <i>快乐自助游</i>
  638. </div>
  639. </a>
  640. </ul>
  641. </div>
  642. </div>
  643. <div class="c-rf">
  644. <a href="">查看更多旅游路线<span class="iconfont icon-arrow-right"></span></a>
  645. </div>
  646. <div class="foot">
  647. <a href=""><span class="iconfont icon-dianhua"></span> <i>客服电话</i> </a>
  648. <a href=""><span class="iconfont icon-bangzhu"></span> <i>帮助中心</i> </a>
  649. <a href=""><span class="iconfont icon-dingdan"></span> <i>我的订单</i> </a>
  650. <a href=""><span class="iconfont icon-guanyuwomen"></span> <i>关于我们</i> </a>
  651. </div>
  652. <div class="c-rf">
  653. <a href="">注册|登录</a>
  654. </div>
  655. </body>
  656. </html>

编写过程中由于网页自适应没有办法,只能调用一个js文件:loading.js

  • 示例图:


  • 使用position:relative对网页元素进行排列。
  • 示例图

  • 示例图
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议