whats the best way to have text inside a svg code?











up vote
0
down vote

favorite












I have a 4 page leaflet (in perspective view) designed with illustrator and exported as SVG .I have some text on each page of the leaflet , its too heavy for web rendering ,(as the text is converted to paths). so I decided to keep the base leaflet as SVG and find a way to simulate perspective in the accompanying text and match it to the leaflets perspective, I also found the scripts to make the perspective happen but as soon as I place (inline)the perspective text in the SVG code it acts in a very different way I've made screenshots of the end result I want to achieve so you can see what I mean.
desired end result image



i use foreignObject tag to implement html inside svg .



code i did and whats happening










share|improve this question






















  • How about SVG’s <text> element?
    – MTCoster
    Nov 17 at 10:59






  • 1




    @MTCoster very difficult to add styles like height or width , or must add each single row of text inside a separated text tag , i tried this before but not a good deal . i think its good to one single row text not a paragraph
    – alireza
    Nov 17 at 11:19












  • Your live example doesn't make it clear what you want to happen there. Is it that the perspective doesn't fit what you want to achieve? Were you unable to position the text correctly? Is it that the div is cut off? (that one is easily corrected with overflow:visble on the foreignObject)
    – ccprog
    Nov 17 at 16:21










  • @ccprog see the page example inspect the text element , its jump out of parent div , see the parent div is in a correct place of its parent , and when you resize window every thing behave responsive except text, in addition even h2 tag and p tag are on a correct way , but text inside them just jump out there . is not it abnormal ?!
    – alireza
    Nov 18 at 11:27












  • I would suggest you don't use a foreignObject. It is not entirely surprising to me that the 3D transform on a <div> inside a <foreignObject> does not behave correctly. You are probing the dark boundary of the browser there :). Why not just pull your <div> out of the SVG and just give it the 3D transform to position it over the correct part of the SVG? You could even put the SVG for one page in the div and then everything on the page would get the correct perspective transform. For example lines would get smaller towards the back.
    – Paul LeBeau
    2 days ago

















up vote
0
down vote

favorite












I have a 4 page leaflet (in perspective view) designed with illustrator and exported as SVG .I have some text on each page of the leaflet , its too heavy for web rendering ,(as the text is converted to paths). so I decided to keep the base leaflet as SVG and find a way to simulate perspective in the accompanying text and match it to the leaflets perspective, I also found the scripts to make the perspective happen but as soon as I place (inline)the perspective text in the SVG code it acts in a very different way I've made screenshots of the end result I want to achieve so you can see what I mean.
desired end result image



i use foreignObject tag to implement html inside svg .



code i did and whats happening










share|improve this question






















  • How about SVG’s <text> element?
    – MTCoster
    Nov 17 at 10:59






  • 1




    @MTCoster very difficult to add styles like height or width , or must add each single row of text inside a separated text tag , i tried this before but not a good deal . i think its good to one single row text not a paragraph
    – alireza
    Nov 17 at 11:19












  • Your live example doesn't make it clear what you want to happen there. Is it that the perspective doesn't fit what you want to achieve? Were you unable to position the text correctly? Is it that the div is cut off? (that one is easily corrected with overflow:visble on the foreignObject)
    – ccprog
    Nov 17 at 16:21










  • @ccprog see the page example inspect the text element , its jump out of parent div , see the parent div is in a correct place of its parent , and when you resize window every thing behave responsive except text, in addition even h2 tag and p tag are on a correct way , but text inside them just jump out there . is not it abnormal ?!
    – alireza
    Nov 18 at 11:27












  • I would suggest you don't use a foreignObject. It is not entirely surprising to me that the 3D transform on a <div> inside a <foreignObject> does not behave correctly. You are probing the dark boundary of the browser there :). Why not just pull your <div> out of the SVG and just give it the 3D transform to position it over the correct part of the SVG? You could even put the SVG for one page in the div and then everything on the page would get the correct perspective transform. For example lines would get smaller towards the back.
    – Paul LeBeau
    2 days ago















up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have a 4 page leaflet (in perspective view) designed with illustrator and exported as SVG .I have some text on each page of the leaflet , its too heavy for web rendering ,(as the text is converted to paths). so I decided to keep the base leaflet as SVG and find a way to simulate perspective in the accompanying text and match it to the leaflets perspective, I also found the scripts to make the perspective happen but as soon as I place (inline)the perspective text in the SVG code it acts in a very different way I've made screenshots of the end result I want to achieve so you can see what I mean.
desired end result image



i use foreignObject tag to implement html inside svg .



code i did and whats happening










share|improve this question













I have a 4 page leaflet (in perspective view) designed with illustrator and exported as SVG .I have some text on each page of the leaflet , its too heavy for web rendering ,(as the text is converted to paths). so I decided to keep the base leaflet as SVG and find a way to simulate perspective in the accompanying text and match it to the leaflets perspective, I also found the scripts to make the perspective happen but as soon as I place (inline)the perspective text in the SVG code it acts in a very different way I've made screenshots of the end result I want to achieve so you can see what I mean.
desired end result image



i use foreignObject tag to implement html inside svg .



code i did and whats happening







html css svg perspective






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 17 at 10:57









alireza

62




62












  • How about SVG’s <text> element?
    – MTCoster
    Nov 17 at 10:59






  • 1




    @MTCoster very difficult to add styles like height or width , or must add each single row of text inside a separated text tag , i tried this before but not a good deal . i think its good to one single row text not a paragraph
    – alireza
    Nov 17 at 11:19












  • Your live example doesn't make it clear what you want to happen there. Is it that the perspective doesn't fit what you want to achieve? Were you unable to position the text correctly? Is it that the div is cut off? (that one is easily corrected with overflow:visble on the foreignObject)
    – ccprog
    Nov 17 at 16:21










  • @ccprog see the page example inspect the text element , its jump out of parent div , see the parent div is in a correct place of its parent , and when you resize window every thing behave responsive except text, in addition even h2 tag and p tag are on a correct way , but text inside them just jump out there . is not it abnormal ?!
    – alireza
    Nov 18 at 11:27












  • I would suggest you don't use a foreignObject. It is not entirely surprising to me that the 3D transform on a <div> inside a <foreignObject> does not behave correctly. You are probing the dark boundary of the browser there :). Why not just pull your <div> out of the SVG and just give it the 3D transform to position it over the correct part of the SVG? You could even put the SVG for one page in the div and then everything on the page would get the correct perspective transform. For example lines would get smaller towards the back.
    – Paul LeBeau
    2 days ago




















  • How about SVG’s <text> element?
    – MTCoster
    Nov 17 at 10:59






  • 1




    @MTCoster very difficult to add styles like height or width , or must add each single row of text inside a separated text tag , i tried this before but not a good deal . i think its good to one single row text not a paragraph
    – alireza
    Nov 17 at 11:19












  • Your live example doesn't make it clear what you want to happen there. Is it that the perspective doesn't fit what you want to achieve? Were you unable to position the text correctly? Is it that the div is cut off? (that one is easily corrected with overflow:visble on the foreignObject)
    – ccprog
    Nov 17 at 16:21










  • @ccprog see the page example inspect the text element , its jump out of parent div , see the parent div is in a correct place of its parent , and when you resize window every thing behave responsive except text, in addition even h2 tag and p tag are on a correct way , but text inside them just jump out there . is not it abnormal ?!
    – alireza
    Nov 18 at 11:27












  • I would suggest you don't use a foreignObject. It is not entirely surprising to me that the 3D transform on a <div> inside a <foreignObject> does not behave correctly. You are probing the dark boundary of the browser there :). Why not just pull your <div> out of the SVG and just give it the 3D transform to position it over the correct part of the SVG? You could even put the SVG for one page in the div and then everything on the page would get the correct perspective transform. For example lines would get smaller towards the back.
    – Paul LeBeau
    2 days ago


















How about SVG’s <text> element?
– MTCoster
Nov 17 at 10:59




How about SVG’s <text> element?
– MTCoster
Nov 17 at 10:59




1




1




@MTCoster very difficult to add styles like height or width , or must add each single row of text inside a separated text tag , i tried this before but not a good deal . i think its good to one single row text not a paragraph
– alireza
Nov 17 at 11:19






@MTCoster very difficult to add styles like height or width , or must add each single row of text inside a separated text tag , i tried this before but not a good deal . i think its good to one single row text not a paragraph
– alireza
Nov 17 at 11:19














Your live example doesn't make it clear what you want to happen there. Is it that the perspective doesn't fit what you want to achieve? Were you unable to position the text correctly? Is it that the div is cut off? (that one is easily corrected with overflow:visble on the foreignObject)
– ccprog
Nov 17 at 16:21




Your live example doesn't make it clear what you want to happen there. Is it that the perspective doesn't fit what you want to achieve? Were you unable to position the text correctly? Is it that the div is cut off? (that one is easily corrected with overflow:visble on the foreignObject)
– ccprog
Nov 17 at 16:21












@ccprog see the page example inspect the text element , its jump out of parent div , see the parent div is in a correct place of its parent , and when you resize window every thing behave responsive except text, in addition even h2 tag and p tag are on a correct way , but text inside them just jump out there . is not it abnormal ?!
– alireza
Nov 18 at 11:27






@ccprog see the page example inspect the text element , its jump out of parent div , see the parent div is in a correct place of its parent , and when you resize window every thing behave responsive except text, in addition even h2 tag and p tag are on a correct way , but text inside them just jump out there . is not it abnormal ?!
– alireza
Nov 18 at 11:27














I would suggest you don't use a foreignObject. It is not entirely surprising to me that the 3D transform on a <div> inside a <foreignObject> does not behave correctly. You are probing the dark boundary of the browser there :). Why not just pull your <div> out of the SVG and just give it the 3D transform to position it over the correct part of the SVG? You could even put the SVG for one page in the div and then everything on the page would get the correct perspective transform. For example lines would get smaller towards the back.
– Paul LeBeau
2 days ago






I would suggest you don't use a foreignObject. It is not entirely surprising to me that the 3D transform on a <div> inside a <foreignObject> does not behave correctly. You are probing the dark boundary of the browser there :). Why not just pull your <div> out of the SVG and just give it the 3D transform to position it over the correct part of the SVG? You could even put the SVG for one page in the div and then everything on the page would get the correct perspective transform. For example lines would get smaller towards the back.
– Paul LeBeau
2 days ago



















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53350536%2fwhats-the-best-way-to-have-text-inside-a-svg-code%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53350536%2fwhats-the-best-way-to-have-text-inside-a-svg-code%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Paul Cézanne

UIScrollView CustomStickyHeader Resize height generates problems when scroll is too fast

Angular material date-picker (MatDatepicker) auto completes the date on focus out