테스트 사이트 - 개발 중인 베타 버전입니다

백그라운드 풀스크린 이미지 적용하기

· 9년 전 · 4182

<!DOCTYPE html>
<html>

<head>
 <meta charset="utf-8">
 
 <title>제목</title>
 
<style>
 * { margin: 0; padding: 0; }

 #bg { position: fixed; top: 0; left: 0; }
 .bgwidth { width: 100%; }
 .bgheight { height: 100%; }
 
 #page-wrap { position: relative; width: 400px; margin: 50px auto; padding: 20px; background: white; -moz-box-shadow: 0 0 20px black; -webkit-box-shadow: 0 0 20px black; box-shadow: 0 0 20px black; }
 p { font: 15px/2 Georgia, Serif; margin: 0 0 30px 0; text-indent: 40px; }
</style>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
 $(function() {  
 
  var theWindow        = $(window),
   $bg              = $("#bg"),
   aspectRatio      = $bg.width() / $bg.height();
         
  function resizeBg() {
   
   if ( (theWindow.width() / theWindow.height()) < aspectRatio ) {
    $bg
     .removeClass()
     .addClass('bgheight');
   } else {
    $bg
     .removeClass()
     .addClass('bgwidth');
   }
      
  }
         
  theWindow.resize(function() {
   resizeBg();
  }).trigger("resize");
 
 });
</script>

</head>

<body>

 <img src="/data/201107/IJ13098874706702/bg.jpg" id="bg" alt="">
 
 <div id="page-wrap">
 
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
  <p>샘플 텍스트</p>
 
 </div>
 
</body>
</html> 

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

게시글 목록

번호 제목
575
547
529
524
523
514
497
496
495
494
493
492
491
490
489
488
487
472
463
461
454
451
450
449
444
440
429
428
426
425