gpt4 book ai didi

css - 如何在 Rails 应用程序中使用 html_safe 修复样式?

转载 作者:行者123 更新时间:2023-11-28 12:57:49 24 4
gpt4 key购买 nike

当我包含“.html_safe”时,我发现样式 (lass = 'lead' style = 'font-size: 14px;') 没有被使用。当我删除 .html_safe 时,我得到了样式,但现在显示了所有 html。

关于如何解决这个问题有什么建议吗?

    <p class = 'lead' style = 'font-size: 14px;'>
<div id = 'textcontainer'>
<%= @chapter.chaptext.html_safe %>
</div> <!-- end of textcontainer div -->
</p>

没有 html 的 @chapter.chaptext 的内容:

<p> Sanjaya said: <a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'>Lord Krishna</a></a></a></a></a></a></a></a></a> spoke these wor<a href = '#' class = 'getannotation'>ds to Arjuna</a> whose eyes were
<a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'>tearful and downcast</a></a>, and who was ov<a href = '#' class = 'getannotation'>erwh</a>elmed <a href = '#' class = 'getannotation'><a href = '#' class = 'getannotation'>with compassion and despair</a></a>.
(2.01) <p>

<p> The Supreme Lord said: How has the dejection come to you at this
juncture? This is n<a href = '#' class = 'getannotation'>ot fit for an Arya</a>n (or the people of noble mind and
deeds). It is disgraceful, and it does not lead one to heaven, O Arjuna.
(2.02)<br>

<p> Do not become a coward, O Arjuna, because it does not befit you. Shake
off this weakness of your heart and get up (for the battle), O Arjuna.
(2.03) <p>

最佳答案

它在没有 .html_safe 的情况下工作,因为 @chapter.chaptexttextcontainer 中被呈现为字符串。我认为问题是 class = 'getannotation' 覆盖了你的风格(lead class)或者可能 id = 'textcontainer' 使用像 #textcontainer 这样的风格规则p { font-size: 20px;}

使用网络检查器工具查看应用于 chaptext 内容的样式及其来源(CSS 类)。

关于css - 如何在 Rails 应用程序中使用 html_safe 修复样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16407055/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com