经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » HTML/CSS » HTML5 » 查看文章
Html5+Css3小试牛刀
来源:cnblogs  作者:勿悲勿急,戒骄戒躁  时间:2019/8/27 9:51:24  对本文有异议

前因:

  我开始做个收款系统,突然客户跑来要插进一个任务,据说他们老板挺在意的,一个小商场,一个首页,一个详情页,UI无自由发挥,要求,尽量好看点。

      一番交谈后,确认这是一个对外的网站,最好移动端也能正常显示(响应式)。

正文:

  前端这一块我一直在想给自己提升一下,刚好有这个机会,于是就去看了一下Html 5和Css3 发现很多属性确实 比以前方便,其中比如 伸缩盒子flex;  里面的flex-direction,align-items,justify-content 属性 布局确实大大方便了。

html  因为html5 的新标签header,footer,article,section,nav等等 加入,布局 不再全部依赖div

  1. 1 <body>
  2. 2 <header>
  3. 3 <img src="Img/logo.png" class="logo" />
  4. 4 <div class="F_Search">
  5. 5 <input type="text" class="Search" id="Search" placeholder="Please enter what you want to find" />
  6. 6 <button class="SearchBtn" onclick="Search('');"></button>
  7. 7 <nav class="SearchText">
  8. 8 <ul>
  9. 9 <li><p onclick="Search('test');">test</p></li>
  10. 10 <li><p onclick="Search('t');">t</p></li>
  11. 11 <li><p onclick="Search('t');">t</p></li>
  12. 12 <li><p onclick="Search('t');">t</p></li>
  13. 13 <li><p onclick="Search('t');">t</p></li>
  14. 14 <li><p onclick="Search('t');">t</p></li>
  15. 15 <li><p onclick="Search('t');">t</p></li>
  16. 16 <li><p onclick="Search('t');">t</p></li>
  17. 17 </ul>
  18. 18 </nav>
  19. 19 </div>
  20. 20 <div class="link">
  21. 21 <img src="Img/link.png" />
  22. 22 <div>
  23. 23 <h2>Call Us Now :</h2>
  24. 24 <span>-------</span>
  25. 25 </div>
  26. 26 </div>
  27. 27 </header>
  28. 28 <article>
  29. 51 </article>
  30. 52 <footer>
  31. 53 <p><img src="Img/logo.png" style="width:40px;height:40px;padding:10px;vertical-align:middle;" /></p>
  32. 57 </footer>
  33. 122 </body>

CSS: 布局采用 flex弹性布局 这里就展示头部样式 ,其他部分 大同小异

  1. 1 * {
  2. 2 margin: 0;
  3. 3 padding: 0;
  4. 4 list-style: none;
  5. 5 text-decoration: none;
  6. 6 }
  7. 7 /*顶部*/
  8. 8 header {
  9. 9 width: 100%;
  10. 10 display: -webkit-flex;
  11. 11 display: flex; /*IE必要元素*/
  12. 12 flex-direction: row;/*排成一行*/
  13. 13 align-items: center; /*上下居中*/
  14. 14 padding: 30px;
  15. 15 box-sizing: border-box;
  16. 16 justify-content: space-between; /*分散内部元素 中间有空白*/
  17. 17 border-bottom: 1px solid #e6e6e6;
  18. 18 }
  19. 19
  20. 20 header .logo {
  21. 21 margin-bottom: 10px;
  22. 22 margin-right: 40px;
  23. 23 border-radius: 5px 5px;
  24. 24 }
  25. 25
  26. 26 header .F_Search {
  27. 27 padding-left: 20px;
  28. 28 flex: 1;
  29. 29 font-size: 0px;
  30. 30 }
  31. 31
  32. 32 header .F_Search .SearchText ul {
  33. 33 font-size: 12px;
  34. 34 display: flex; /*IE必要元素*/
  35. 35 flex-direction: row;
  36. 36 }
  37. 37
  38. 38 header .F_Search .SearchText ul li {
  39. 39 padding: 10px;
  40. 40 padding-top: 5px;
  41. 41 box-sizing: border-box;
  42. 42 cursor: pointer;
  43. 43 color: #A599B0;
  44. 44 }
  45. 45
  46. 46 header .Search {
  47. 47 width: 80%;
  48. 48 height: 35px;
  49. 49 border-radius: 10px 0 0 10px;
  50. 50 border: 1px solid #F9C801;
  51. 51 vertical-align: middle;
  52. 52 }
  53. 53
  54. 54 header .SearchBtn {
  55. 55 width: 20%;
  56. 56 vertical-align: middle;
  57. 57 border: 0px;
  58. 58 height: 37px;
  59. 59 width: 60px;
  60. 60 border-radius: 0 10px 10px 0;
  61. 61 background: url('../Img/search2.png') no-repeat center center;
  62. 62 background-color: #F9C801;
  63. 63 cursor: pointer;
  64. 64 }
  65. 65
  66. 66 header .link {
  67. 67 display: -webkit-flex;
  68. 68 display: flex; /*IE必要元素*/
  69. 69 flex-direction: row;
  70. 70 align-items: center;
  71. 71 }
  72. 72
  73. 73 header .link img {
  74. 74 padding-left: 20px;
  75. 75 padding-right: 20px;
  76. 76 }
  77. 77
  78. 78 header .link img:hover {
  79. 79 transform: rotate(360deg);
  80. 80 transition: transform 2s;
  81. 81 }
  82. 82
  83. 83 header .link h2 {
  84. 84 color: #596794;
  85. 85 }
  86. 86
  87. 87 header .link span {
  88. 88 padding-left: 20px;
  89. 89 color: #596794;
  90. 90 }

@media only screen and (min-width: 320px) and (max-width: 1000px) {
header {
top: 0;
position: fixed;
padding: 0px;
width: 100%;
}
header .F_Search {
width:100%;
font-size: 0px;
}
header .logo,header .link,header .SearchText{
display: none;
}
}

 

原文链接:http://www.cnblogs.com/666qq/p/11416333.html

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号