HTML 内容的 Wrap 失败 [英] Wrap fails for HTML content

查看:37
本文介绍了HTML 内容的 Wrap 失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾尝试包装 HTML CMS 内容,但失败了.

I have tried to wrap HTML CMS content, but it fails.

这是我试过的代码:

<h3>Wrap Example</h3>
<cfset test='<h4><span>This is failure wrap function</span></h4><span><h5>This is failure wrap function</h5></span>'>
<cfoutput>#Wrap(test, 10)#</cfoutput>

结果如下:

 Wrap Example

 This is failure wrap function< /span>

 This is failure wrap function< /h5>

如何解决这个问题?

推荐答案

根据 它的文档wrap() 操作一个字符串,而不是一个HTML 片段.虽然后者是前者,但前者并不意味着对后者的任何理解.wrap() 看到的都是字符串数据……它不知道您传递给它的某些字符串是 HTML,因此不能简单地用换行符中断 HTML 标记.

As per its docs, wrap() operates on a string, not a fragment of HTML. Whilst the latter is the former, the former does not imply any understanding of the latter. All wrap() sees is string data... it does not know that some of the string you are passing it is HTML, and accordingly one cannot simply interrupt an HTML tag with a line break character.

所以基本上这里没有什么可以修复"的,因为您只是使用了不合适的工具来完成这项工作.

So basically there's nothing to "fix" here, as you're just using the inappropriate tool for the job.

怀疑你应该做的是将文本放在 spandiv 或其他容器标签中,并且然后将包含标签的样式设置为您想要的宽度.我认为,将字符串分成多个字符并不是您想要完成的任务的真正方法?

I suspect what you should be looking at doing is putting the text within a span or a div or some other container tag, and then style that containing tag to have the width that you want. Chopping the string up into numbers-of-characters is not really how to approach the task you're wanting to accomplish, I think?

您为什么要尝试将这个标记包装"在 10 个字符处?

Why is it you're trying to do, in "wrapping" this mark-up at 10 characters?

这篇关于HTML 内容的 Wrap 失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆