长沙专业网站建设,网站栏目建设图,可以自己做歌曲的网站,wordpress虚拟模板要了解和熟悉 HTML5 中的新的语义元素#xff0c;最好的方式就是拿一经典的 HTML 文档作例子#xff0c;然后把 HTML5 的一些新鲜营养充实进入。如下就是我们要改造的页面#xff0c;该页面很简单#xff0c;只包含一篇文章。 ApocalypsePage_Original.html#xff0c;这是…要了解和熟悉 HTML5 中的新的语义元素最好的方式就是拿一经典的 HTML 文档作例子然后把 HTML5 的一些新鲜营养充实进入。如下就是我们要改造的页面该页面很简单只包含一篇文章。 ApocalypsePage_Original.html这是一个格式非常规范的页面所有的样式均来自于外部样式表。 !DOCTYPE html
html langzh-CN
headmeta charsetutf-8titleApocalypse Now/titlelink relstylesheet hrefApocalypsePage_Original.css
/headbody
div classHeaderh1How the World Could End/h1p classTeaserScenarios that spell the end of life as we know/pp classBylineby Ray N. Carnation/p
/div!-- end Header --div classContentpspan classLeadInRight now/span, youre probably feeling pretty good. After all, life in the developed world is comfortablespan classstyle1—/spanprobably more comfortable than its been for the average human being throughout all of recorded history./ppBut dont get too smug. Theres still plenty of horrific ways it could all fall apart. In this article, youll learn about a few of our favorites./ph2Mayan Doomsday/h2pSkeptics suggest that the Mayan calendar simply rolls to a new 5,126-year era after 2012, and doesnt actually predict a life-ending apocalypse. But given that the long-dead Mayans were wrong about virtually everything else, why should we trust them on this?/ph2Robot Takeover/h2pNot quite as frightening as a Vampire Takeover or Living-Dead Takeover, a robot rebellion is still a disquieting thought. We are already outnumbered by our technological gadgets, and even Bill Gates fears the day his Japanese robot slave turns him over by the ankles and asks (in a suitably robotic voice) Whos your daddy now?/ph2Unexplained Singularity/h2pWe dont know how the universe started, so we cant be sure it wont just end, maybe today, and maybe with nothing more exciting than a puff of anti-matter and a slight fizzing noise./ph2Runaway Climate Change/h2pDismissed by some, Al Gores prophecy of doom may still come true. If it does, we may have to contend with vicious storms, widespread food shortages, and surly air conditioning repairmen./ph2Global Epidemic/h2pSome time in the future, a lethal virus could strike. Predictions differ about the source of the disease, but candidates include monkeys in the African jungle, bioterrorists, birds and pigs with the flu, warriors from the future, an alien race, hospitals that use too many antibiotics, vampires, the CIA, and unwashed brussel sprouts. Whatever the source, its clearly bad news./p/div!-- end Content --div classFooterp classDisclaimerThese apocalyptic predictions do not reflect the views of the author./ppa hrefAboutUs.htmlAbout Us/aa hrefDisclaimer.htmlDisclaimer/aa hrefContactUs.htmlContact Us/a/ppCopyright © 2014/p
/div!-- end Footer --
/body
/html 在不增加任何 CSS 样式表之前效果如下 上面通过三个 div 将页面分成了三个部分顶部的页眉中部的内容和底部的页脚。 这个例子中的样式表很简单整个页面最大宽度设置为 800 像素避免文本在宽屏显示器上显示过长。页眉位于一个带有蓝色边框的盒子中内容区的两侧都增加了内边距而页脚在整个页面的底部居中。 ApocalypsePage_Original.css 样式文件内容如下 charset utf-8;
/* CSS Document */
body{/*font-family 要使用安全字体按照先特殊后一般的原则先给出你想要的字体然后是保险一些的字体最后以 sans-serif 字体结尾*/font-family: Lucida sans Unicode, Lucida Grande, Geneva, sans-serif;max-width: 800px; /*最大宽度不超过 800 像素*/
}/*页面顶部的标题区样式*/
.Header {background-color: #7695FE; /*可接受任何颜色值*/border: thin #336699 solid; /*多合一的 border 属性*/padding: 10px; /* 10像素的内边距边框与内容之间的距离*/margin: 10px; /* 10像素的外边距边框与周围元素之间的距离*/text-align: center; /*头部文本居中*/
}/*页眉中标题h1样式*/
.Header h1{margin: 0px;color: white;font-size: xx-large; /*精确控制可以用像素或者em单位*/
}/*页眉中子标题样式*/
.Header .Teaser{margin: 0px;font-weight: bold;
}/*页眉中署名行样式*/
.Header .Byline{font-style: italic;font-size: small;margin: 0px;
}.Content{font-size: medium;font-family: Cambria, Cochin, Georgia, Times New Roman, Times, serif;/*左右内边距最大*/padding-top: 20px;padding-right: 50px;padding-bottom: 5px;padding-left: 50px;line-height: 120%; /*相邻两个文本行之间的距离*/
}.Content .LeadIn{font-weight: bold;font-size: large;font-variant: small-caps;
}.Content .h2{color: #24486C;margin-bottom: 2px;font-size: medium;
}.Content p{margin-top: 0px;
}.Footer{text-align: center;font-size: x-small;
}.Footer .Disclaimer{font-style: italic;
}.Footer p{margin: 3px;
} 这样我们的样式表就弯沉过了现在去看看结果会怎样呢如下图 使用 HTML5 来构造页面 div 目前仍旧是 Web 设计的必备元素它是一个直观、多用途的容器可以通过它为页面中的任何区块应用样式。但 div 的问题在于它本身不反映与页面相关的任何信息。 要通过 HTML5 改进这种情况可以把 div 替换成更具有描述性语义的元素。 ApocalypsePage_Revised.html 中已经将 class 属性为 Header 和 Footer 两个 div 替换为 header 和 footer部分代码如下 headerh1How the World Could End/h1p classTeaserScenarios that spell the end of life as we know/pp classBylineby Ray N. Carnation/p
/header
...
footerp classDisclaimerThese apocalyptic predictions do not reflect the views of the author./ppa hrefAboutUs.htmlAbout Us/a
.../ppCopyright © 2014/p
/footer 当然对应的 ApocalypsePage_Revised.css 文件也需要进行修改将其中的 .Header 和 .Footer 替换为 header 和 footer。部分代码如下 /*页面顶部的标题区样式*/
header {background-color: #7695FE; /*可接受任何颜色值*/border: thin #336699 solid; /*多合一的 border 属性*/padding: 10px; /* 10像素的内边距边框与内容之间的距离*/margin: 10px; /* 10像素的外边距边框与周围元素之间的距离*/text-align: center; /*头部文本居中*/
}/*页眉中标题h1样式*/
header h1{margin: 0px;color: white;font-size: xx-large; /*精确控制可以用像素或者em单位*/
} 最后还有一个元素需要用在示例文件中就是 article 元素表示一个完整的、自成一体的内容。 ariticle 元素应该包含新闻报道或文章的内容包括标题、署名和正文。因此添加了 article 元素后的结构如下 articleheaderh1How the World Could End/h1p classTeaserScenarios that spell the end of life as we know/pp classBylineby Ray N. Carnation/p/header div classContentpspan classLeadInRight now/span, youre probably feeling pretty good. After all, life in the developed world is comfortablespan classstyle1—/spanprobably more comfortable than its been for the average human being throughout all of recorded history./p
.../div!-- end Content --
/article 重新设计后页面结构如下 用 figure 添加插图 很多页面都是包含图片的。但是插图 (figure) 与图片的概念还不完全一样。插图虽然独立于文本但是文本中会提到它。 一般来说插图应该是浮动的还会有浮动图题。下面是在文章中添加插图的 HTML 标记在正文的第一段和第二段之间的位置部分代码如下 ...
div classContentpspan classLeadInRight now/span, youre .../p div classFloatFigureimg srchuman_skull.jpg altHuman skullpWill you be the last person standing if one of these apocalypticscenarios plays out?/p/divpBut dont get too smug. Theres.../p
... 相应的 样式表规则如下 .FloatFigure{float: left;margin: 0px 20px 0px 0px;
}.FloatFigure p{max-width: 300px;font-size: small;font-style: italic;margin-bottom: 5px;
} 下图展示了这个示例的外观插图恰好在第一段文本之后浮动在后面文本的左侧图题的文本的宽度我们限制住了让图题显示很充实、很优雅。 HTML5 中提供了一个 figure 元素图题可以放在 figure 中的 figcaption 元素里经过改造代码如下 figure classFloatFigureimg srchuman_skull.jpg altHuman skullfigcaptionWill you be the last person standing if one of these apocalypticscenarios plays out?/figcaption
/figure 当然样式表中的选择符相应修改一下即可。 .FloatFigure{float: left;margin: 0px 20px 0px 0px;
}.FloatFigure figcaption{max-width: 300px;font-size: small;font-style: italic;margin-bottom: 5px;
} 最后还有就是 img 元素中的 alt 属性可以删除掉因为图题中包含了图片的完整说明。 用 aside 添加附注 新的 aside 元素表示与它周围的文本没有密切关系的内容。可以通过它介绍另一个相关的话题或者对主文档中提出的某个观点进行解释。还可以用来放置广告、相关内容链接。 下面的示例中将用作醒目引文pull quote使用 div 元素可以创造这种效果但是用 aside 元素让标记更有意义 部分代码如下 p... (in a suitably robotic voice) Whos your daddy now?/paside classPullQuoteimg srcquotes_start.png altQuoteWe dont know how the universe started, so we cant be sure it wont just end, maybe today.img srcquotes_end.png altEnd quote/asideh2Unexplained Singularity/h2 对应的样式表内容如下 .PullQuote{float: right;max-width: 300px;border-top: thin black solid;border-bottom: thick black solid;font-size: 30px;line-height: 130%;font-style: italic;padding-top: 5px;padding-bottom: 5px;margin-left: 15px;margin-bottom: 10px;
}.PullQuote img{vertical-align: bottom;
} 示例代码 ApocalypsePage.rar转载于:https://www.cnblogs.com/pchmonster/p/4824893.html