CSS from freecodecamp

完整代码in gist:
catApp-CSS
catApp-CSS+bootstrap

html

  1. in CSS style element, classes should start with a period. 如果直接给h,p这样的元素加属性,不需要period
<style>
    .blue-text {
        color: blue;
      }
     p {
        font-size: 16px;
        font-family:Sans-serif;
      }
</style>
.
.
<p class=".blue-text">ppp</p>
  1. import google font
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
  1. if you wanted an element to use the Helvetica font, but also degrade to the Sans-Serif font when Helvetica wasn't available, you could use this CSS style:
p {
  font-family: Helvetica, Sans-Serif;
}
  1. All img elements must have an alt attribute. The text inside an alt attribute is used for screen readers to improve accessibility and is displayed if the image fails to load.

  2. 给img加一个边框

 .thick-green-border {
    border-color: green;
    border-width: 10px;
    border-style: solid;
//这个radius可以设成px,现在这个50%的效果是把方形图片变成圆形很好看
    border-radius: 50%;
  }
  1. Nesting just means putting one element inside of another element.

  2. Make Dead Links using the Hash Symbol

 <a href="#">cat photos</a>
  1. Your placeholder text is what appears in your text input
    before your user has input anything.
<input type="text" placeholder="this is placeholder text">
  1. form
<form action="/url-where-you-want-to-submit-form-data"></form>
  1. if you wanted to make a text input field required, you can just add the word required within your input element, you would use:
 <input type="text" required>
  1. radio buttons H5中的单选框吧
    for questions where you want the user to only give you one answer.
<label><input type="radio" name="indoor-outdoor"> Indoor</label>
  1. checkbox
<label><input type="checkbox" name="personality"> Loving</label>
  1. checked 就是默认标记吧,有checked的直接默认被选中
<label><input type="checkbox" checked name="personality"> Loving</label>
  1. id 除了class外下一个attr,jquery 的时候很有用,都可以在css中指明位置设置样式,class前面 必须有. id前面必须有#
  2. Inherit Styles from the Body Element
<style>
  body {
    background-color: black;
    font-family: Monospace;
    color: green;
  }
</style>
<h1>Hello World!</h1>
//helloworld是绿色
  1. 如果遇到冲突:
    class= “class1 class2” class2(在css style里后设置的)会生效,
    class 和id, id不论先设置还是后设置都会生效( id declarations override class declarations, regardless of where they are declared )
    inline style优先级比id更高
    css中!important比inline高

css/style !important>inline style>id>class2>class1

#orange-text {
    color: orange;
  }
  .pink-text {
    color: pink !important;
  }
  .blue-text {
    color: blue;
  }
</style>
<h1 id="orange-text" class="pink-text blue-text" style="color: white">Hello World!</h1>
  1. You can use spans to create inline elements.

Bootstrap

  1. Font Awesome is a convenient library of icons.
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"/>
  1. iatlic 斜体的
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • FreeCodeCamp - HTML5 and CSS 发现原来在另外一台电脑学 FreeCodeCamp 的时...
    付林恒阅读 13,121评论 2 17
  • 问答题47 /72 常见浏览器兼容性问题与解决方案? 参考答案 (1)浏览器兼容问题一:不同浏览器的标签默认的外补...
    _Yfling阅读 14,687评论 1 92
  • 我是一名游戏行业从业者,每次讨论、汇报、开会等等场景听到别人说“你这个产品如何如何”、“哪个哪个产品有特色去研究下...
    黑色旅人阅读 4,852评论 0 2
  • 产科的最后一周是在门诊度过的,要走时王老师问了一句:你想去哪个科?下意识回答:生殖。又问:第二备选呢?想了想说:妇...
    菁小清阅读 2,801评论 1 2
  • 1 天空的脸娃娃脸,刚刚还晴空万里,突然之间狂风大作,黑云如大海的波浪翻滚涌动。倾盆大雨骤然而下,雨珠垂直而降,就...
    和风轻和阅读 3,517评论 0 4