0
내가하고 싶은 일은 2 개의 실린더가있는 svg 파일을 만드는 것입니다. 다른 하나는 탱크와 액체를 나타내는 것입니다. 나는 내부 실린더가 주어진 액체의 비율에 따라 움직이기를 원한다. 나는 이것을 달성했으며 코드는 js 바이올린에서 잘 작동한다. 하지만 svg 파일을 html로 통합하려고 할 때 내부 실린더가 작동하지 않습니다. jsfiddle에 사용 http://jsfiddle.net/7op7re9j/3/SVG 파일 스크립트가 html로 작동하지 않습니다.
코드 :
<div class="progressBar">
<svg width="580" height="400" xmlns="http://www.w3.org/2000/svg">
<!-- Created with Method Draw - http://github.com/duopixel/Method-Draw/ -->
<g>
<title>background</title>
<rect height="402" width="582" y="-1" x="-1" fill="#fff" id="canvas_background"/>
</g>
<defs>
<style type="text/css">
<![CDATA[
.stop1 { stop-color: grey; }
.stop2 { stop-color: black; stop-opacity: 0; }
.stop3 { stop-color: grey; }
]]>
</style>
<linearGradient id="Gradient1">
<stop offset="0%" class="stop1"/>
<stop offset="50%" class="stop2"/>
<stop offset="100%" class="stop3"/>
</linearGradient>
</defs>
<g>
<title>Layer 1</title>
<path d="m527,77.53519c0,33.2677 -102.30249,60.23117 -228.49918,60.23117m228.49918,-60.23117l0,0c0,33.2677 -102.30249,60.23117 -228.49918,60.23117c-126.19745,0 -228.50072,-26.96347 -228.50072,-60.23117m0,0l0,0c0,-33.28308 101.42944,-62.78519 227.62694,-62.78519c126.19666,0 229.37296,29.50211 229.37296,62.78519l0,240.97189c0,33.26648 -102.30249,60.24292 -228.49918,60.24292c-126.19745,0 -228.50072,-26.97644 -228.50072,-60.24292l0,-240.97189z" stroke-width="1.5" stroke-opacity="null" stroke="#000" fill-opacity="null" fill="rgb(255, 215, 0)" id="svg_2"/>
<rect height="225" width="10" y="90.77" x="51.75" stroke-width="1.5" stroke-opacity="null" stroke="#000" fill-opacity="null" fill="#fff68f" id="svg_3"/>
<rect height="13.5" width="10" y="319.77" x="51.75" stroke-width="1.5" stroke-opacity="null" stroke="#000" fill-opacity="null" fill="#ff0000" id="svg_7"/>
<rect height="13.5" width="10" y="73.77" x="51.75" stroke-width="1.5" stroke-opacity="null" stroke="#000" fill-opacity="null" fill="#ff0000" id="svg_8"/>
<path d="m527,71.58089c0,34.05788 -102.75073,61.6671 -229.49994,61.6671m229.49994,-61.6671l0,0c0,34.05788 -102.75073,61.6671 -229.49994,61.6671c-126.74753,0 -229.50006,-27.60924 -229.50006,-61.6671m0,0l0,0c0,-34.0567 102.75255,-61.66643 229.50006,-61.66643c126.74921,0 229.49994,27.60972 229.49994,61.66643l0,246.66637c0,34.05798 -102.75073,61.66721 -229.49994,61.66721c-126.74753,0 -229.50006,-27.60922 -229.50006,-61.66721l0,-246.66637z" stroke-width="2" stroke-opacity="5.5" stroke="#000" fill-opacity="null" fill="url(#Gradient1)" id="svg_5"/>
<path d="m171.4028,276.6062l314.99991,0c-34.79343,0 -63.00003,103.42236 -63.00003,231c0,127.57776 28.2066,231 63.00003,231l-314.99991,0l0,0c-34.79411,0 -63.00003,-103.42224 -63.00003,-231c0,-127.57767 28.20592,-231 63.00003,-231z" transform="rotate(-90 297.403 507.606)" stroke-width="0.005" stroke-opacity="null" stroke="#000" fill-opacity="null" fill="#fff" id="svg_9"/>
</g>
<script><![CDATA[
var path = document.getElementById('svg_2');
var liqpercent=50;
var cal=100-liqpercent;
var segments = path.pathSegList;
segments.getItem(0).y = 77+(2.4*cal);
]]>
</script>
</svg>
hi..i 대신 크롬의 예에서 코드를 실행하려고 다시 작업을 시작 shoulds 그것은 잘 작동했다 . 하지만 난 두 브라우저에서 작동 싶어요. 누구든지 나를 도울 수 있습니까? –