2017-10-27 8 views
0

봐 :왜 배경 크기 : 100 % 100 %; 이 SVG에서 작동하지 않습니까? 이 예에서

.container { 
 
    background-image:url("http://svgshare.com/i/3cM.svg"); 
 
    background-position:center center; 
 
    background-repeat:no-repeat; 
 
    width:400px; 
 
    height:200px; 
 
    background-color:#eef; 
 
    border-bottom:1px solid #000; 
 
    background-size:100% 100%; 
 
}
<div id="container1" class="container"></div>

관련 질문 : Stretch a background image (SVG) to 100% width and 100% height? 주석의 제안으로

+0

100 %를 사용하여 컨테이너 내에 다른 elem을 중첩시켜야한다고 생각합니다. –

+0

실례로이 예제는 작동하지 않습니다. 특정 SVG 파일에 문제가 있습니까? – Blackbam

+0

http://jsfiddle.net/JknDr/123/ -이 기능은 Chrome에서 나에게 적합합니다. 신장이 문제라면, 더 비례하여 비례하는 svg를 찾아야 할 수도 있습니다. –

답변

1

은 .svg 파일을 열고 SVG 태그 안에

preserveAspectRatio="none"

을 설정합니다.

+0

관련 찾음 : https://stackoverflow.com/questions/9334095/background-size100-100-doesnt-work-properly-in-chrome – Blackbam

0

가, 또 다른 하나의 내부 SVG 컨테이너를 포장하고 래퍼에게 당신이 필요로하는 크기를 제공합니다. 이 경우 래퍼를 100vw 너비 및 100vh 높이로 설정합니다. 래퍼 크기를 변경하고 svg가 이어지는 것을 확인하십시오.

html, body { 
 
    padding:0; 
 
    margin:0; 
 
} 
 

 
.wrapper { 
 
    width:100vw; 
 
    height:100vh; 
 
} 
 

 
.container { 
 
    background-image:url("http://svgshare.com/i/3cM.svg"); 
 
    background-position:center center; 
 
    background-repeat:no-repeat; 
 
    width:100%; 
 
    height:100%; 
 
    background-color:#eef; 
 
    border-bottom:1px solid #000; 
 
    background-size:100% 100%; 
 
}
<div class="wrapper"> 
 
    <div id="container1" class="container"></div> 
 
</div>