开发问题集

来源:互联网 发布:apple mac mini 编辑:程序博客网 时间:2024/04/30 12:24

1.疑问拿到一个640*1136的设计图,开发中怎么高度还原?

   在chrome中f12手机模式,选中iphone5,是320*568的,而实际上iphone5的高大上Retina屏是640*1136的分辨率,Retina屏和普屏分辨率恰好是两倍。在开发中,我们按320*568开发即可,拿到设计稿,扔进ps里,把量到的长宽除以2就是啦。

更多阅读:

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

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

2.透明背景,内容文字不透明

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

   rgba中的alpha和opacity区别是什么?没错,就是不会对子元素产生影响

更多阅读:

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


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 
  });
});

0 0
原创粉丝点击