2016-06-29 4 views
1

전체 브라우저 화면을 커버하기 위해 CSS에서 배경 이미지를 만들 수 있지만 크기가 작을수록 이미지의 크기가 커지면 이미지가 더 길어지는 방법이 있습니까?"height : 100 %;"를 사용하지 않고 전체 브라우저 창을 커버하는 배경 이미지 CSS

CSS를 높이 100 %로 설정하면 모바일 반응이 없지만 높이를 100 % 설정하지 않으면 브라우저 화면 전체가 표시되지 않습니다.

CSS

.about{ 
    background: url("city.jpg") no-repeat center center fixed; 
    -webkit-background-size: cover; 
    -moz-background-size: cover; 
    -o-background-size: cover; 
    background-size: cover; 
} 
+2

나는 ' 첫 번째 문장을 파싱하는 데 문제가 있습니다. 두 개의 스크린 샷이 엄청난 도움이 될 것입니다. –

+0

또한 [이 기사] (https://css-tricks.com/perfect-full-page-background-image/)가 도움이 될 수 있습니다. –

답변

3

예, 하나는 몸에 배경 이미지 ...

body{ 
 
    background: url(http://lorempizza.com/500/500) no-repeat center center; 
 
    -webkit-background-size: cover; 
 
    -moz-background-size: cover; 
 
    -o-background-size: cover; 
 
    background-size: cover; 
 
}
<section id="about" class = "about"> 
 
     <div class="container"> 
 
     <div class="row"> 
 
      <br><br> 
 
      <h1>My Journey</h1> 
 
       <div class="col-lg-6"> 
 
        <div class="panel panel-default"> 
 
         <div class="panel-body"> 
 
         <p>Having been a dilligent, hard working student in Malahide Community School, I only had one thing I really wanted to study in college - business! When I didn't get the grades for my first choice of business and economics in Trinity, I turned to my second choice - Computer Science and Business. Having gone through a recent name change from Business and Computing, I thought how hard could it really be? </p> 
 
         </div> 
 
        </div> 
 
        
 

 
        <div class="panel panel-default"> 
 
         <div class="panel-body"> 
 
         <p>So, final year came and went.. Some fun, a bit of stress and a fantastic way to end a great four years. What made the experience even better, was achieving a fantastic final grade, which made the time spent worth it! </p> 
 
         </div> 
 
        </div> 
 
       </div> 
 
       <div class="col-lg-6"> 
 
        <br><br><br><br><br><br> 
 
        <div class="panel panel-default"> 
 
         <div class="panel-body"> 
 
         <p>When I got to college, I had a tough time getting my head around most of the programming modules that were part of the course. It was like nothing I'd ever seen before. A far cry from the spread sheets I thought I'd be filling in. Having reached the end of the year, exam time arrived and I ended up failing two programming modules - bye bye summer! But I got through the repeats, and funnily enough, ended up learning a lot about myself, and more importantly: programming! </p> 
 
         </div> 
 
        </div> 
 
       </div> 
 
     </div> 
 
     </div> 
 
    </section>
또는 section 커버 전신을 설정하여

html, body { 
 
    margin: 0; 
 
} 
 

 
.about{ 
 
    min-width: 100vw; 
 
    min-height: 100vh; 
 
    background: url(http://lorempizza.com/500/500) no-repeat center center; 
 
    -webkit-background-size: cover; 
 
    -moz-background-size: cover; 
 
    -o-background-size: cover; 
 
    background-size: cover; 
 
}
<section id="about" class = "about"> 
 
     <div class="container"> 
 
     <div class="row"> 
 
      <br><br> 
 
      <h1>My Journey</h1> 
 
       <div class="col-lg-6"> 
 
        <div class="panel panel-default"> 
 
         <div class="panel-body"> 
 
         <p>Having been a dilligent, hard working student in Malahide Community School, I only had one thing I really wanted to study in college - business! When I didn't get the grades for my first choice of business and economics in Trinity, I turned to my second choice - Computer Science and Business. Having gone through a recent name change from Business and Computing, I thought how hard could it really be? </p> 
 
         </div> 
 
        </div> 
 
        
 

 
        <div class="panel panel-default"> 
 
         <div class="panel-body"> 
 
         <p>So, final year came and went.. Some fun, a bit of stress and a fantastic way to end a great four years. What made the experience even better, was achieving a fantastic final grade, which made the time spent worth it! </p> 
 
         </div> 
 
        </div> 
 
       </div> 
 
       <div class="col-lg-6"> 
 
        <br><br><br><br><br><br> 
 
        <div class="panel panel-default"> 
 
         <div class="panel-body"> 
 
         <p>When I got to college, I had a tough time getting my head around most of the programming modules that were part of the course. It was like nothing I'd ever seen before. A far cry from the spread sheets I thought I'd be filling in. Having reached the end of the year, exam time arrived and I ended up failing two programming modules - bye bye summer! But I got through the repeats, and funnily enough, ended up learning a lot about myself, and more importantly: programming! </p> 
 
         </div> 
 
        </div> 
 
       </div> 
 
     </div> 
 
     </div> 
 
    </section>

1

제거는 '고정'-이 당신을 위해 무엇을 찾고있는 생각합니다.

+0

하지만 여전히 브라우저 창의 높이가되고 싶습니다. 그게 가능하니? 즉. 나는 여전히 선 높이를 원한다 : 100 %; 그러나 모바일 응답 성을 원합니다. – user2026178

+1

상황을 진단하는 데 도움이되는 전체 컨텍스트가 필요합니다. JSFiddle을 설정하는 것이 좋습니다 –

+1

JFiddle에서의 시도는 다음과 같습니다. [link] (https://jsfiddle.net/higginni/at5ka5ua/1/) @Spencer .... 내가 찾고있는 것은 배경 이미지입니다. 내 브라우저 창의 전체 높이가되지만 모바일 장치 크기로 창의 크기가 조정될 때 본질적으로 150 %가됩니다 (예 :). – user2026178

관련 문제