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

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

· 9년 전 · 4189

<!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> 

댓글 작성

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

로그인하기

게시글 목록

번호 제목
928
894
893
892
888
887
885
884
880
879
877
874
873
872
871
870
869
868
865
861
860
859
858
855
854
853
852
851
850
849