Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to place my svg into a div

New Here ,
Dec 05, 2017 Dec 05, 2017

Hi,

i made my first svg with animate cc and im trying to make it work on my website now. Unfortunately it is always appent to "body". How to place it into a div of my choice?

Hope some have some hints for me!

Edit: Forget to say that i installed the snap.svg plugin.

- Tobias

714
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 06, 2017 Dec 06, 2017
Community Expert ,
Dec 05, 2017 Dec 05, 2017

i don't know how you're using snap.svg but you there are a number of ways to add svg to a web page:

image - How to use .svg files in a webpage? - Stack Overflow

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 05, 2017 Dec 05, 2017

Let me be clearer. This is the code that is generated by snap.svg to load the svg and append to body. How to place the svg into a <div>?

<script type="text/javascript">

var jsonfile = "<?=get_bloginfo('stylesheet_directory')?>/js/SnapSVGAnimator/swb-ani.json",

    fps = 24,

    width = 200,

    height = 200,

    AJAX_req;

AJAX_JSON_Req(jsonfile);

function handle_AJAX_Complete() {

    if( AJAX_req.readyState == 4 && AJAX_req.status == 200 )

    {

        json = JSON.parse(AJAX_req.responseText);

        comp = new SVGAnim(

           json,

           width,

           height,

           fps

           );

    }

}

function AJAX_JSON_Req( url )

{

    AJAX_req = new XMLHttpRequest();

    AJAX_req.open("GET", url, true);

    AJAX_req.setRequestHeader("Content-type", "application/json");

   

    AJAX_req.onreadystatechange = handle_AJAX_Complete;

    AJAX_req.send();

}

</script>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 06, 2017 Dec 06, 2017
LATEST
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines