查看: 3550|回复: 1

一起学html5 第一课,简单了解

[复制链接]

1

主题

5

回帖

242

积分

会员

理想主义者

Rank: 5Rank: 5

积分
242
QQ
发表于 2012-4-18 18:01:41 | 显示全部楼层 |阅读模式
尹广磊公众帐号
首先要说一下,我是有div+css基础的,我也期望和我一起学习的人对div+css能有一定的了解。

译言网翻译了一套不错的教程,以下的笔记均是通过学习这篇文章记录的:http://select.yeeyan.org/view/213582/204942

html5的好处我就不介绍了,吵得这么热一定有优势,我们的目的就是学会使用html5,其他的在使用过程中慢慢感悟吧

我们先从一个例子来学习吧
两个文件:主页面main.html和样式表main-stylesheet.css
main.html代码如下,笔记记录其中:
  1. <!doctype html>
  2. <html lang="en">
  3. //html5的头部没有那么多格式要求了,就这么写就可以了。en可以换成其他语言编码


  4. <head>//head区和以前没有太大差别,放置样式和js代码以及title,keywords等信息的地方
  5. <title>HTML5 Fundamentals Example</title>
  6. <link rel="stylesheet" href="main-stylesheet.css" kesrc="main-stylesheet.css" />
  7. </head>


  8. <body>


  9. <header>//header是html5新增的一个标签,header区主要展示页面的头部,放置一些大标题之类的文档。
  10. <hgroup>//在header区里面还有一个hgroup标签,这也是html5新增标签,用于对网页或区段(section)的标题进行组合。
  11. <h1>Acme United</h1>
  12. <h2>A Simple HTML5 Example</h2>
  13. </hgroup>
  14. </header>



  15. <nav>//html5新增标签nav,用来定义网页的主导航
  16. <ul>
  17. <li><a href="#" kesrc="#">Home</a></li>
  18. <li><a href="#" kesrc="#">About Us</a></li>
  19. <li><a href="#" kesrc="#">Contact Us</a></li>
  20. </ul>
  21. </nav>



  22. <article>//html5新增标签article,该区域存放了页面的实际内容,以后不用到处都是div了

  23.         <header>//注意注意,header区域并不是头部才会有的,在任何一个区域都可以出现header,代表这个区域的大标题
  24.                 <h1>
  25.                         <a href="#" kesrc="#" title="Link to this post" rel="bookmark">Article Heading</a>
  26.                 </h1>
  27.         </header>

  28.        


  29.         <p> Primum non nocere ad vitam Paramus . . . </p>

  30.         <section>
  31.                 <header>
  32.                         <h1>This is the first section heading</h1>
  33.                 </header>
  34.                 <p>Scientia potentia est qua nocent docentp . . .</p>
  35.         </section>


  36.         <section>
  37.         //<section>标签用于分组的内容,<section>标签和<article>标签通常以一个<header>为开始并以一个<footer>结束,标签的内容则放在这两者之间。<section>标签也可以包含<article>标签,就像<article>标签可以包含<section>标签一样。section多表示并列的内容,article多表示完整的内容。

  38.                 <header>
  39.                 <h1>Second section with mark, aside, menu & figure</h1>
  40.                 </header>
  41.                 <p class="next-to-aside"> . . . <mark>veni, vidi, vici</mark>. Mater . . .</p>

  42.                 <aside>//这一标签被看作是用来存放补充内容的地方,这些内容不是其所补充的一篇连续文章的组成部分。我理解这个标签就是放置在主内容旁边的区域类似经常用的样式sidebar
  43.                         <p>This is an aside that has multiple lines. . . .</p>
  44.                 </aside>

  45.                 <menu label="File">//menu标签与nav不同,相当于小的btn组合
  46.                         <button type="button" onClick="JavaScript:alert('Clio . . .')">Clio</button>
  47.                         <button type="button" onClick="JavaScript:alert('Thalia . . .')">Thalia</button>
  48.                         <button type="button" onClick="JavaScript:alert('Urania . . .')">Urania</button>
  49.                         <button type="button" onClick="JavaScript:alert('Calliope . . .')">Calliope</button>
  50.                 </menu>
  51.                 <figure>//figure标签放图片
  52.                         <img src="stonehenge.jpg" kesrc="stonehenge.jpg" alt="Stonehenge" width="200" height="131"/>
  53.                         <figcaption>Figure 1. Stonehenge</figcaption>//figcaption放图片标题
  54.                 </figure>
  55.         </section>

  56.         <section>
  57.                 <header>
  58.                         <h1>This is a video section</h1>
  59.                 </header>
  60.                 <p>
  61.                         <video src="http://people.xiph.org/~maikmerten/demos/BigBuckBunny.ogv" kesrc="http://people.xiph.org/~maikmerten/demos/BigBuckBunny.ogv"
  62.                         controls autoplay loop>
  63.                         <div class="no-html5-video"><p>This video will work in
  64.                         Mozilla Firefox or Google Chrome only. </p>
  65.                         </div>
  66.                         </video>//video标签放video……汗……
  67.                 </p>
  68.         </section>
  69. </article>


  70. <footer>//footer元素包含了与页面、文章或是部分内容有关的信息,比如说文章的作者或是日期。作为页面的页脚,其有可能包含了版权或是其他重要的法律信息
  71. <p>Copyright: 2011 Acme United. All rights reserved.</p>
  72. </footer>



  73. </body>
  74. </html>
复制代码
main-stylesheet.css 代码如下,笔记记录其中:
  1. * {
  2. font-family: Lucida Sans, Arial, Helvetica, sans-serif;
  3. }

  4. body {
  5. width: 800px;
  6. margin: 0em auto;
  7. }

  8. header h1 {
  9. font-size: 50px;
  10. margin: 0px;
  11. color: #006;
  12. }

  13. header h2 {
  14. font-size: 15px;
  15. margin: 0px;
  16. color: #99f;
  17. font-style: italic;
  18. }

  19. nav ul {//nav不是一个class,前面不用加“.”
  20. list-style: none;
  21. padding: 0px;
  22. display: block;
  23. clear: right;
  24. background-color: #99f;
  25. padding-left: 4px;
  26. height: 24px;
  27. }
  28. nav ul li {
  29. display: inline;
  30. padding: 0px 20px 5px 10px;
  31. height: 24px;
  32. border-right: 1px solid #ccc;
  33. }

  34. nav ul li a {
  35. color: #006;
  36. text-decoration: none;
  37. font-size: 13px;
  38. font-weight: bold;
  39. }

  40. nav ul li a:hover {
  41. color: #fff;
  42. }

  43. article > header h1 {//设置article中的header样式,使用了">"的方式
  44. font-size: 40px;
  45. float: left;
  46. margin-left: 14px;
  47. }

  48. article > header h1 a {
  49. color: #000090;
  50. text-decoration: none;
  51. }

  52. article > section header h1 {
  53. font-size: 20px;
  54. margin-left: 25px;
  55. }

  56. article p {
  57. clear: both;
  58. margin-top: 0px;
  59. margin-left: 50px;
  60. }

  61. article p.next-to-aside {
  62. width: 500px;
  63. }

  64. article > section figure {
  65. margin-left: 180px;
  66. margin-bottom: 30px;
  67. }

  68. article > section > menu {
  69. margin-left: 120px;
  70. }

  71. aside p {
  72. position:relative;
  73. left:0px;
  74. top: -100px;
  75. z-index: 1;
  76. width: 200px;
  77. float: right;
  78. font-style: italic;
  79. color: #99f;
  80. }


  81. article > section video {
  82. height: 200px;
  83. margin-left: 180px;
  84. }

  85. article > section div.no-html5-video{
  86. height: 20px;
  87. text-align: center;
  88. color: #000090;
  89. font-size: 13px;
  90. font-style: italic;
  91. font-weight: bold ;
  92. background-color: #99f;
  93. }

  94. footer p {
  95. text-align: center;
  96. font-size: 12px;
  97. color: #888;
  98. margin-top: 24px;
  99. }
复制代码

test01.zip

1.68 KB, 下载次数: 0

0

主题

31

回帖

202

积分

会员

Rank: 5Rank: 5

积分
202
QQ
发表于 2012-8-31 09:58:04 | 显示全部楼层
顶了~!
您需要登录后才可以回帖 登录 | 新用户注册

本版积分规则

QQ|手机版|友情链接|版权声明|关于我们|Axure中文社区 |网站地图

GMT+8, 2024-5-16 10:35

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表