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

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

· 9년 전 · 4187

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

댓글 작성

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

로그인하기

게시글 목록

번호 제목
415
412
411
410
409
408
407
406
403
390
389
387
381
378
370
363
356
354
353
350
348
346
345
344
343
341
333
329
328
325