javascript - How can I use inline SVG multiline text with LTR and RTL support -
i have created inline svg multiline text.
i want make ltr
(left right) , rtl
(right left) support. possible solve scss/css or javascript.
i have added code , breaks svg image on rtl
view.
$(document).ready(function() { $("#btn").on('click', function() { if($('html').is("[dir=rtl]")){ $('html').attr('dir', 'ltr'); } else { $('html').attr('dir', 'rtl'); } }); });
body{ background: #f3f5f6; } .center{ text-align: center; } .dtls { opacity: 1; } .clip { clip-path: url(#clip-cm); } .fill-theme { fill: #fff; } .fill-theme { fill-rule: evenodd; } .cardoverlaybg { opacity: 0.6; } .infotextcolor { fill: #fefffa; font-size: 22px; font-weight: 600; } .textcontent { font-size: 16px; font-weight: 400; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <div class="center"> <a href="javascript:;" id="btn">toggle ltr - rtl</a> </div> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewbox="0 0 954 640"> <defs> <clippath id="clip-cm"> <rect width="954" height="640"/> </clippath> </defs> <g id="cm" class="clip cm"> <g id="ae" class="dtls" transform="translate(155 20)"> <rect id="ae-card" class="fill-theme" width="544" height="326" rx="5" transform="translate(19 19)"/> <path id="ae-bg" class="cardoverlaybg" d="m19,204h563v341a4,4,0,0,1-4,4h23a4,4,0,0,1-4-4z"/> <text id="ae-text" class="infotextcolor" transform="translate(304.311 244.328)"><tspan x="-129.052" y="0">lorem, ipsum (dolor sit)</tspan><tspan class="textcontent"><tspan x="-133.136" y="19.2">amet consectetur adipisicing elit adip </tspan><tspan x="-122.504" y="38.4">deserunt: impedit, reprehenderit</tspan><tspan x="-181.704" y="57.6">reprehenderit ducimus culpa, cumque aperiam cumque</tspan><tspan x="-144.04" y="76.8">dolor illum error | optio inventore ducimus</tspan></tspan></text> </g> </g> </svg>
Comments
Post a Comment