Css3

491 views

Published on

Published in: Technology, Art & Photos
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
491
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Css3

  1. 1. HTML5 开发Web,MobileWeb & Apps范圣刚安博中程在线
  2. 2. CSS3 / STYLING设计更丰富的样式,排版和布局吧!
  3. 3. CSS3 边框
  4. 4. 圆角Web页面元素默认都是长方形的,我们需要为这些元素添加圆角效果,使用户界面看起来更柔和一些。下列浏览器支持 border-radius 属性:IE9+, Firefox 4+, Chrome, Safari 5+, and Opera.安博中程在线<style>.round-border {border-radius: 10px;-moz-border-radius: 10px;-webkit-border-radius: 10px;}</style><img src="/images/border.png" class="round-border">HTML4/24
  5. 5. Gravatar 头像使用百分比安博中程在线<style>.gravatarimg{border-radius:50%50%50%50%;}</style><divclass="gravatar"><imgsrc="/demo/css3/images/gravatar.jpeg"></div>HTML5/24
  6. 6. 边框阴影安博中程在线<style>div.shadow_box{box-shadow: 10px 10px 5px #999;width: 300px;height: 100px;background-color: yellow;}</style>HTML水平偏移量, 正数代表阴影会出现在右边,负数左边;垂直偏移量, 正数代表阴影会出现在目标元素的下面,负数上面;模糊半径,值越大,阴影越模糊。阴影的颜色下列浏览器支持 box-shadow 属性: IE9+, Firefox 4, Chrome, Opera, and Safari 5.1.1。text-shadow 属性被所有的主流浏览器支持, 除了IE。······6/24
  7. 7. 边框图片border-image 属性指定使用图片作为边框。平铺效果拉伸效果原图:安博中程在线#round {border-image:url(borderimage.png) 30 30 round;}#stretch {border-image:url(borderimage.png) 30 30 stretch;}HTML7/24
  8. 8. CSS3 变换和动画
  9. 9. 旋转Rotate安博中程在线transform:rotate(-10deg);-ms-transform:rotate(-10deg);/*IE9*/-moz-transform:rotate(-10deg);/*Firefox*/-webkit-transform:rotate(-10deg);/*SafariandChrome*/-o-transform:rotate(-10deg);/*Opera*/HTML9/24
  10. 10. 缩放安博中程在线#dnd-thumbnailsimg:hover{-webkit-transform:scale(2.0)rotate(10deg);-webkit-transform-origin:50%75px;-moz-transform:scale(2.0)rotate(10deg);-moz-transform-origin:50%75px;margin:0100px;}HTML10/24
  11. 11. Transition安博中程在线指定给哪些CSS属性添加效果;指定效果时长;··div.width-effect {width:100px;transition: width 1s;}div.width-effect:hover {width:500px;}HTML11/24
  12. 12. 动画安博中程在线@keyframes myfirst {from {background:red;}to {background:yellow;}}#animation:hover {animation:myfirst 3s;-moz-animation:myfirst 3s; /* Firefox */-webkit-animation:myfirst 3s; /* Safari and Chrome */-o-animation:myfirst 3s; /* Opera */}CSS@keyframe规则指定animation的名字和时长使用from和to指定开始和完成也可以使用百分比形式····12/24
  13. 13. 指定百分比安博中程在线#animation2 {width:100px;height:100px;background:red;position:relative;animation-name:mySecond;animation-duration:5s;animation-timing-function:linear;animation-delay:2s;animation-iteration-count:infinite;animation-direction:alternate;animation-play-state:running;}@keyframes mySecond{0% {background:red; left:0px; top:0px;}25% {background:yellow; left:200px; top:0px;}50% {background:blue; left:200px; top:200px;}75% {background:green; left:0px; top:200px;}100% {background:red; left:0px; top:0px;}}HTML13/24
  14. 14. 动画Demo安博中程在线 14/24
  15. 15. 动画Demo安博中程在线 15/24
  16. 16. Multiple Columns主要的属性设置安博中程在线.newspaper {column-count:3;column-gap:40px;column-rule:2px outset #333;}HTMLcolumn-count: 分几栏column-gap: 栏间距column-rule: 设置栏属性(宽度,样式,颜色)···16/24
  17. 17. 分栏前Tips for Designing Great Icons and ImagesBeautiful, compelling icons and images are a fundamental part of the iOS user experience. Far from beingmerely decorative, the icons and images in your app play an essential role in communicating with users.For the best results, enlist the help of a professional graphic designer. An experienced graphic designercan help you develop an overall visual style for your app and apply that style to all the icons and images init.Use universal imagery that people will easily recognize. Avoid focusing on a secondary or obscure aspectof an element.Embrace simplicity. In particular, avoid cramming lots of different images into your icon. Try to use asingle object that expresses the essence of your app. Start with a basic shape and add details cautiously. Ifan icon’s content or shape is overly complex, the details can become confusing and may appear muddy atsmaller sizes.Tips for Creating Great Artwork for the Retina DisplayUse color and shadow judiciously to help the icon tell its story. Don’t add color just to make the icon morecolorful. Also, smooth gradients typically work better than sharp delineations of color.安博中程在线 17/24
  18. 18. Tips for Designing Great Icons and ImagesBeautiful, compelling icons and images are a fundamental part of the iOS user experience. Far from beingmerely decorative, the icons and images in your app play an essential role in communicating with users.For the best results, enlist the help of a professional graphic designer. An experienced graphic designercan help you develop an overall visual style for your app and apply that style to all the icons and images init.Use universal imagery that people will easily recognize. Avoid focusing on a secondary or obscure aspectof an element.Embrace simplicity. In particular, avoid cramming lots of different images into your icon. Try to use asingle object that expresses the essence of your app. Start with a basic shape and add details cautiously. Ifan icon’s content or shape is overly complex, the details can become confusing and may appear muddy atsmaller sizes.Tips for Creating Great Artwork for the Retina DisplayUse color and shadow judiciously to help the icon tell its story. Don’t add color just to make the icon morecolorful. Also, smooth gradients typically work better than sharp delineations of color.In general, avoid using “greek” text or wavy lines to suggest text. If you want to show text in your icon, butyou don’t want to draw attention to the words themselves, start with actual text and make it hard to readby shrinking it or doubling the layers.Don’t reuse iOS app icons in your interface. It can be confusing to users to see the same icon used tomean slightly different things in multiple locations throughout the system.安博中程在线 18/24
  19. 19. CSS3 的选择器
  20. 20. 奇偶行不同颜色显示安博中程在线传统做法是给奇偶行设置不同的css类名使用:nth-of-type可以查找特定类型的第n个页面元素,结合even和odd关键字实现“斑马纹”效果。··tr:nth-of-type(even){background-color: #F3F3F3;}tr:nth-of-type(odd) {background-color:#ddd;}CSS20/24
  21. 21. 除第一列外其他列文本右对齐安博中程在线td:nth-child(n+2){text-align: right;}CSS查找某元素的子元素,和nth-of-type一样,也可以使用关键字或者公式。公式:an+b,a是倍数,b是偏移量。··table tr:nth-child(n+2): 除第一行外的所有行;table tr:nth-child(2n): 每两行选择一行;table tr:nth-child(2n+4): 用偏移量改变起始行,从第四行开始隔一行选择一行;···21/24
  22. 22. 最后一行加粗显示获取一组元素中的最后一个子元素安博中程在线tr:last-child{font-weight:bolder;}CSS22/24
  23. 23. 倒数第二行用不同颜色显示从最后一个元素反向查找安博中程在线tr:nth-last-child(2){color:green;}tr:nth-last-child(-n+3)td{text-align:right;}CSS23/24
  24. 24. <Thank you!>微博 @范圣刚博客 www.tfan.orggithub github.com/princetoad

×