发表日期:2018-11 文章编辑:小灯 浏览次数:1133
为了让从来没有接触过web前端的小伙伴们,通过短时间的学习,快速完成一个页面的编写,老手请别过,本文将以最直接粗暴的方式快速完成一个H5页面的代码编写。
每日优鲜图片.png打开您的编辑器(随便一种,初学者建议使用hbuilder),新建一个html文件demo.html,输入一下内容,开始的时候您可以直接复制粘贴,然后自己写一遍。
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <!-- div标签 --> <div> 我是div标签1 </div> <div> 我是div标签2 </div><p>我是p标签1</p> <p>我是p标签2</p><input /> <img src="logo.png"/> <button>按钮</button> </body> </html> 知识点讲解:
效果图
image.png<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style type="text/css"> .div1 { /*背景颜色*/ background: gray; /*宽*/ width: 300px; /*高*/ height: 100px; /*边框*/ border: 5px solid green; /*字体大小*/ font-size: 30px; /*字体颜色*/ color: white; /*圆角*/ border-radius: 10px; /*left center right*/ text-align: center; } .div2 { /*元素与外部的距离*/ margin-top: 50px; /*元素顶部与内容的距离*/ padding-top: 10px; padding-left: 10px; background: orange; width: 200px; height: 200px; }</style> </head> <body> <div class="div1"> 我是div1标签 </div> <div class="div2"> 我是div2标签 </div> </body> </html> 说明:
有了上面的html和css知识后,我们就可以编写每日优鲜的页面了。
代码如下:
<!DOCTYPE html> <html><head> <meta charset="UTF-8"> <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no,width=device-width"> <title></title> <style type="text/css"> .top { width: 100%; }.input-box { margin-top: 28px; padding-left: 33px; padding-right: 33px; } .text { border-bottom: 1px solid #e2e2e2; padding-bottom: 18px; } .text input { font-size: 14px; outline: none; } .btn-box{ margin-top: 30px; text-align: center; } .btn { width: 311px; height: 44px; background: #fc4c91; color: #fff; outline: none; border-radius: 6px; font-size: 16px; } .tip { text-align: center; } .bottom { width: 100%; } </style> </head><body> <img class="top" src="img1.png" /> <div class="input-box"> <div class="text"> <input type="text" placeholder="请输入您的手机号" /> </div> </div> <div class="btn-box"> <button class="btn">现在领取</button> </div> <p class="tip"> 领劵后可购买,优质生鲜1小时达 </p> <img class="bottom" src="img2.png" /> </body></html> 说明: