Top

[jquery] À̹ÌÁö , µ¿¿µ»ó ÀÚµ¿ ¸®»çÀÌ¡! | Web-Programing
±è°æÈÆ (admin) | Editor | 2013/04/17 16:08:33 | Á¶È¸:5900

À̹ÌÁö ÀÚµ¿ ¸®»çÀÌ¡

  

  1.   function imgProportion($targetWidth, $targetHeight) 
  2. var DeviceWidth = parseInt($(window).width()-15); //È­¸éÀÇ °¡·Î »çÀÌÁî
  3. var a1 = DeviceWidth * $targetHeight; //À̹ÌÁö ¼¼·Î»çÀÌÁî °è»ê½Ä  
  4. var newHeight = (a1 / $targetWidth); //À̹ÌÁö ¼¼·Î»çÀÌÁî °è»ê½Ä  
  5. var rtnSize = new Array((DeviceWidth), newHeight);   //¸®»çÀÌ¡ µÈ À̹ÌÁö »çÀÌÁî ¸®ÅÏ
  6.  
  7. return rtnSize; 
  8. }

  9. $("img", main).each(function() //À̹ÌÁö¸¦ FIND.
  10. {
  11. var $this = $(this); //¼±ÅÃÀÚ¸¦ ÁöÁ¤.  
  12. var $thisWidth = parseInt($this.css("width")); //¼±ÅÃµÈ À̹ÌÁöÀÇ °¡·Î»çÀÌÁî.
  13. var $thisHeight = parseInt($this.css("height")); //¼±ÅÃµÈ À̹ÌÁöÀÇ ¼¼·Î»çÀÌÁî.  
  14. var clientWidth = parseInt($(window).width()); //È­¸éÀÇ °¡·Î»çÀÌÁî.
  15. if($thisWidth > clientWidth) //À̹ÌÁö °¡·Î°¡ È­¸éÀÇ °¡·Îº¸´Ù ±æ´Ù¸é..
  16. {
  17. var rtn = imgProportion($thisWidth, $thisHeight);
  18. var newWidth = rtn[0]; //Return µÈ ¹è¿­ÀÇ 0¹ø° °ª.  
  19. var newHeight = rtn[1];   //Return µÈ ¹è¿­ÀÇ 1¹ø° °ª.
  20.  
  21. $this.css({  //¼±ÅÃµÈ À̹ÌÁö¿¡ CSS¸¦ º¯°æ.
  22.  
  23. "width"  : newWidth,  
  24. "height" : newHeight
  25. })
  26. });
 

µ¿¿µ»ó ÀÚµ¿ ¸®»çÀÌ¡

 

  1. // µ¿¿µ»óÀ» °øÀ¯ÇÑ »çÀÌÆ®ÀÇ À̸§À» ¹è¿­·Î ÀúÀåÇÑ´Ù.
  2. // »õ·Î¿î »çÀÌÆ®³ª ¾ø¾îÁø »çÀÌÆ®°¡ ÀÖÀ¸¸é ±×¶§ ±×¶§ ¾÷µ¥ÀÌÆ® ÇØÁÖ¼¼¿ä~

  3. var $allVideos = $("iframe[src^='http://player.vimeo.com'], iframe[src^='http://www.youtube.com'], iframe[src^='http://www.youtube-nocookie.com'], iframe[src^='http://serviceapi.nmv.naver.com'],  iframe[src^='http://serviceapi.rmcnmv.naver.com'], embed[src^='http://www.youtube.com'], embed[src^='http://serviceapi.nmv.naver.com'], iframe[src^='https://www.youtube.com'], iframe[src^='https://www.youtube-nocookie.com'], iframe[src^='http://flvs.daum.net'], iframe[src^='http://play.pullbbang.com'], iframe[src^='http://www.gamespot.com'], iframe[src^='http://sbsplayer.sbs.co.kr/'], iframe[src^='http://www.microsoft.com'], iframe[src^='http://dotsub.com'], iframe[src^='http://www.travelro.co.kr'], embed[src^='http://v.egloos.com/v.sk/'],  embed[src^='http://videofarm.daum.net/']  ,embed[src^='http://api.v.daum.net/'], embed[src^='http://dory.mncast.com/'], embed[src^='http://play.mgoon.com/Video/'], embed[src^='http://doc.mgoon.com/'], embed[src^='http://flvr.pandora.tv/flv2pan/'], embed[src^='http://imgcdn.pandora.tv/'], embed[src^='http://live.afreeca.com'], embed[src^='http://afbbs.afreeca.com'], embed[src^='http://w.blogdoc.nate.com'], embed[src^='http://blogdoc.nate.com'], embed[src^='http://www.musicshake.com/'], embed[src^='http://static.plaync.co.kr'], iframe[src^='http://www.travelro.co.kr'], iframe[src^='http://dotsub.com']"),
  4.  $fluidEl = $("body"); // ÀÚµ¿¸®»çÀÌ¡À» Àû¿ëÇÒ ¿µ¿ªÀÇ ID°ª
  5. $allVideos.each(function() 
  6. {
  7.  $(this)
  8.    .data('aspectRatio', this.height / this.width)
  9.    // ±âÁ¸ ³ô,³Ð »èÁ¦
  10.    .removeAttr('height')
  11.    .removeAttr('width');
  12. });
  13. $(window).resize(function() 
  14. {
  15.  var newWidth = $fluidEl.width();
  16.  $allVideos.each(function() 
  17.  {
  18.    var $el = $(this);
  19.    $el
  20.      .width('100%') // ¿øÇϴµ¥·Î~~
  21.      .height('260'); // ¿øÇϴµ¥·Î~~
  22.  });
  23. }).resize();
 


ÀÌ»ó! ÀÔ´Ï´Ù. 

¸ð¹ÙÀÏÀº ¹°·Ð PC¹öÀü¿¡¼­µµ Àû¿ë °¡´É ÇÕ´Ï´Ù.


PC¹öÀü!

¸ð¹ÙÀϹöÀü!

°øÀ¯Çϱâ
°øÀ¯Çϱâ
0
0
0


´ñ±ÛÀ» ºÒ·¯¿À´Â ÁßÀÔ´Ï´Ù.
¡ã ÀÌÀü±Û [javascript] IE¿¡¼­ ÄíÅ° »ý¼ºÀÌ ¾ÈµÇ´Â Çö»ó ( iframe ) ½ÅÀå¹Ì (shinjm) 2013-04-30 17:46:37
¡å ´ÙÀ½±Û [HTML] .slideDown() ±è°æÈÆ (admin) 2013-04-04 10:57:58