Задать вопрос
@AlTerminator

Как задать img источник из svg inline?

Нужно, чтобы у img src был равен изображению из svg.

<!DOCTYPE html>
<html>
 <head>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
 </head>
 <body onload="OnLoad()">
  <?xml version="1.0" encoding="UTF-8" standalone="no" ?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg onclick="SvgLogoClick()" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="172" height="32" viewBox="0 0 172 32" xml:space="preserve"> <desc></desc> <rect x="0" y="0" width="100%" height="100%" fill="transparent"></rect> <g transform="matrix(0 0 0 0 0 0)" id="ab89e07f-1442-43df-bb69-1ec894fd456a"> </g> <g transform="matrix(1 0 0 1 86 16)" id="1fbb36a9-15d3-4ba8-b58d-3b0aa80f1c18"> <rect id="RectBG" style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: transparent; fill-rule: nonzero; opacity: 1;" vector-effect="non-scaling-stroke"  x="-86" y="-16" rx="0" ry="0" width="172" height="32"/> </g> <g transform="matrix(0 0 0 0 0 0)"> <g> </g> </g> <g transform="matrix(0 0 0 0 0 0)"> <g> </g> </g> <g transform="matrix(0 0 0 0 0 0)"> <g> </g> </g> <g transform="matrix(0 0 0 0 0 0)"> <g> </g> </g> <g transform="matrix(0 0 0 0 0 0)"> <g> </g> </g> <g transform="matrix(0 0 0 0 0 0)"> <g> </g> </g> <g transform="matrix(0 0 0 0 0 0)"> <g> </g> </g> <g transform="matrix(0 0 0 0 0 0)"> <g> </g> </g> <g transform="matrix(0 0 0 0 0 0)"> <g> </g> </g> <g transform="matrix(0 0 0 0 0 0)"> <g> </g> </g> <g transform="matrix(0 0 0 0 0 0)"> <g> </g> </g> <g transform="matrix(0 0 0 0 0 0)"> <g> </g> </g> <g transform="matrix(0 0 0 0 0 0)"> <g> </g> </g> <g transform="matrix(0 0 0 0 0 0)"> <g> </g> </g> <g transform="matrix(0 0 0 0 0 0)"> <g> </g> </g> <g transform="matrix(0 0 0 0 0 0)"> <g> </g> </g> <g transform="matrix(0 0 0 0 0 0)"> <g> </g> </g> <g transform="matrix(0 0 0 0 0 0)"> <g> </g> </g> <g transform="matrix(0 0 0 0 0 0)"> <g> </g> </g> <g transform="matrix(0 0 0 0 0 0)"> <g> </g> </g> <g transform="matrix(0 0 0 0 0 0)"> <g> </g> </g> <g transform="matrix(0 0 0 0 0 0)"> <g> </g> </g> <g transform="matrix(0 0 0 0 0 0)"> <g> </g> </g> <g transform="matrix(0 0 0 0 0 0)"> <g> </g> </g> <g transform="matrix(0 0 0 0 0 0)"> <g> </g> </g> <g transform="matrix(0 0 0 0 0 0)"> <g> </g> </g> <g transform="matrix(0.32 0 0 0.32 15.33 16)" id="7f53d056-24ba-4c38-9fbb-39099604a94d"> 	<image style="stroke: none; stroke-width: 0; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: #000000; fill-rule: nonzero; opacity: 1;" vector-effect="non-scaling-stroke"  xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAAAXNSR0IArs4c6QAAD7VJREFUeF7tXQ1sHMUV/tZ3ts8OUCeY1CGGOikudgHh/EBSQMW0ECIQBVqgDRW/RVGBAiqgIqhIaGhAikQEDSIgqAKIQipSkTQkCn8KgYSmlUnchh+rSRVDLuSEg30mJr4733mbN7cz3t3bu53d273bizzCCr6bmZ33vnk/896btYLxFigOKIFazfhiMA5IwDbBOCDjgASMAwFbTikkpFOjudf0b8BYkbOcGwHQmvlPSdbrByAEwA0A6N8WCyreBbDlyHfPa8SWhFCJhwRi3V4D8hCAxRLE8y43acA4GOJL11VHNgdJhEwjiaF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g5ADFIhh/5c1npWQV0LwE6dL6wpxc4Zdeh71dqQAQYJBnvAz3NDu+euyHSbozpdF/WJFYpARFg0P+cDQzWu3xpph2D3Xxvyl6VDZRSASLCHyQZnwKJSLbwwNGbGdww2skYEzPKEnYpFSDCVPhZTG3BfEflQq1AVJf2dXwdzQn4+fqWAhDh0f4aOLjSWaW5I4aaiKQiNUcXi9JAtBqsopEXX5dcdfkNiKGap5welezupRfWTDJeOi2p6vIbECEdfla1yzK7QD+DJN4KHJR4g5AHj82dwk9ADO+9Yn+Kp/TNzfU0lFNK/ARESMc+IN089jae0sPi4onzgdgbYzaoZLbET0DYucPPV2W44LN+SEGHYTfQ+70x416yui6/ABHqys/7HkUCYjvcVENUEuPuFyDiIFiJ6oojZcqjlCRM7xcgzH4EWF3ZSgd1MBn3ktQG+wVI0O2HFCDUSaenSmJH/AJE9eM1fXm4WMxp3hYYk+Hwi19iHX49QK1kY65HyXRI9N2w+wEI87CCGCaheyNNQEedgxiXyXBUJiCdwF6qcNO3z7RfvPpr8LyAi+Yl5S57T43G8b9xQbrOXDmnf9m/xZy+V9P7ISHEevYHU2wVdOV1qEgJITbzN0ZXHsvzr5i/gdtXmvySEF8XfTRPPg5IwNAdB2QckIBxIGDLGZeQcUACxoGALWdcQgIGyP8BqC4LsDiE87wAAAAASUVORK5CYII=" x="-50" y="-50" width="100" height="100"></image> </g> <g transform="matrix(0.19 0 0 0.19 101.6 16)" id="882d3729-3beb-4d12-a29d-ee9b20efa81c"> 	<text id="TextLogo" xml:space="preserve" font-family="Raleway" font-size="105" font-style="normal" font-weight="900" style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-dashoffset: 0; stroke-linejoin: miter; stroke-miterlimit: 4; fill: #000000; fill-rule: nonzero; opacity: 1; white-space: pre;" ><tspan x="-318.02" y="32.98" >ГОСТСТРОЙ</tspan></text> </g></svg>
  <img src="" alt="">
  <script>
   function OnLoad(){
      document.querySelector("img").src = ""; //Что прописать в источнике img?
   }
  </script>
 </body>
</html>
  • Вопрос задан
  • 133 просмотра
Подписаться 1 Средний 13 комментариев
Решения вопроса 1
@AlTerminator Автор вопроса
Нужно использовать <use>
Ответ написан
Комментировать
Пригласить эксперта
Ответы на вопрос 1
NikFaraday
@NikFaraday
Student full-stack Developer
Вы можете вывести изображение в формате svg прямо а html разметку и работать с ним± как с img. Попробуйте открыть svg в любом редакторе текста/кода и перекопировать его содержимое в свой html. Так же рекоменду почитать про svg хотя бы в этой статье
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы