前言:
1.HTML5的发展非常迅速,可以说已经是前端开发人员的标配,在电商类型的APP中更是运用广泛,这个系列的文章是本人自己整理,尽量将开发中不常用到的剔除,将经常使用的拿出来,使需要的朋友能够真正快速入门,如果有哪些不清楚的地方或者错误,欢迎联系我 2.更新时间没有规律,一般会在3天左右更新一篇(全系列预计会有12篇)因为需要工作,所以只能在闲暇之余整理,如果有喜欢的朋友可以关注我,将会第一时间获得更新信息 3.如果有需要Reactive Native + H5跨平台开发的朋友,可以联系我,在本系列结束之前会根据需求的程度决定是否继续 4.全系列文章最后尽可能地附上综合实例,帮助朋友更好地理解 5.此系列会涉及到HTML、CSS、JavaScript等
另:有很多朋友私聊我说图片不能正常显示的问题,测试后发现简书上可以在windows和mac端完美显示,如果看不到图片麻烦移步简书链接
首先,网页会有默认边距,我们需要先将其归置为0,方便我们后面的计算和调试,设置的方式很多,一般偷懒的我喜欢使用通配符 ‘*’ 来直接设置,而像百度等大公司则是将可能使用到的标签全部取出设置(如下图),这么做的原因可能是考虑到性能问题吧,因为通配符是设置所有的标签,从理论上来说性能应该是最差的,这边就先不纠结了
*{ margin:0; padding: 0; } /*设置整体的a标签样式*/ a{ /*设置文字颜色*/ color: black; /*去除下划线*/ text-decoration: none; /*字体颜色*/ color: grey; } 这边我们使用的是外部样式的css,所以先来引入外部css文件<!--引入外部样式css--> <link rel="stylesheet" href="css/index.css">效果:
先来设置头部的样式
.header{ /*设置顶部背景颜色,方便调试*/ /*background-color: yellow;*/ /*设置高度*/ height: 60px; /*设置间距*/ margin: 20px 120px 0 120px; } .header-lefticon{ /*垂直居中*/ line-height: 60px; /*靠左悬浮*/ float: left; } .header-rightlogin{ /*垂直居中*/ line-height: 60px; /*靠右悬浮*/ float: right; } .header-rightlogin a{ /*设置边框*/ border: 1px solid black; /*设置内边距*/ padding: 5px 10px; /*设置右间距*/ margin-right: 20px; /*字体颜色*/ color: black; }效果:
接下来是内容的样式
.content{ /*设置顶部背景颜色,方便调试*/ /*background-color: green;*/ /*设置内容水平居中*/ text-align: center; /*高*/ /*height: 600px;*/ position: absolute; left: 0px; bottom: 60px; display: inline-block; width: 100%; } .content-logo{ /*设置顶部背景颜色,方便调试*/ /*background-color: red;*/ /*水平居中*/ margin: 0 auto; /*设置内容水平居中*/ text-align: center; width: 200px; margin-top: 100px; } .content-search{ /*设置顶部背景颜色,方便调试*/ /*background-color: rebeccapurple;*/ /*高度*/ height: 40px; /*设置宽度*/ width: 600px; /*使文字居中*/ text-align: center; margin: 0 auto; } .content-search input{ /*宽度*/ width: 500px; /*高度*/ height: 40px; /*边框*/ border: 3px solid greenyellow; box-sizing: border-box; } .content-search a{ background-color: greenyellow; /*设置文字颜色*/ color: white; /*改变标签类型*/ display: inline-block; /*设置高度和宽度*/ height:100%; width: 100px; /*浮动在右边*/ float: right; /*垂直居中*/ line-height: 40px; } .content-language{ margin-top: 200px; } .content-language a{ border: 1px solid black; /*字体颜色*/ color: black; }效果:
再来就是尾部的样式了
.footer{ /*background-color: rebeccapurple;*/ position: absolute; left: 20px; bottom: 0px; right: 20px; height: 60px; } .footer-left{ /*悬浮左边*/ float: left; line-height: 60px; margin: 0 auto; /*字体大小*/ font-size: 15px; } .footer-right{ /*悬浮右边*/ float: right; line-height: 60px; margin: 0 auto; /*字体大小*/ font-size: 15px; /*字体颜色*/ color: grey; }效果:
OK,这样是不是和目标网页的样子差不多了?有些细节大家可以自己试着调一下最后给大家提供一个必备的网站,W3school里面包含了所有标签的属性,使用,JavaScript等你需要的东西,很方便很好用
转载于:https://www.cnblogs.com/miaomiaoshen/p/5604507.html
相关资源:移动互联网之路:HTML5 CSS3 jQuery Mobile APP与移动网站设计从入门到精通.李晓斌(带详细书签).pdf