頁面開發問題集

1.疑問拿到一個640*1136的設計圖,開發中怎麼高度還原?css

   在chrome中f12手機模式,選中iphone5,是320*568的,而實際上iphone5的高大上Retina屏是640*1136的分辨率,Retina屏和普屏分辨率剛好是兩倍。在開發中,咱們按320*568開發便可,拿到設計稿,扔進ps裏,把量到的長寬除以2就是啦。html

更多閱讀:css3

http://www.zhihu.com/question/20583941?group_id=114817350web

http://www.cnblogs.com/BigPolarBear/archive/2012/03/26/2417777.htmlchrome

2.透明背景,內容文字不透明iphone

    background: rgba(255,255,255,.7); //正道!
     //background: #fff;
     //opacity: 0.7;this

   rgba中的alpha和opacity區別是什麼?沒錯,就是不會對子元素產生影響spa

更多閱讀:設計

http://kayosite.com/css3-rgba-color.htmlcode


3.新生成的元素動態綁定

錯誤示範:

$(document).ready(function() {
  $(".add").click(function() {

    $(this).addClass('cancel');
    $(this).removeClass('add'); 
  });
  $(".cancel").click(function() {//後來才生成的.cancel,這樣是木有反應的。。。

    $(this).removeClass('cancel');
    $(this).addClass('add');
  });
});

人間正道:

$(document).ready(function() {  $(document).on("click", ".add", function() {   // code here   });  $(document).on("click", ".cancel", function() {   // code here   });});