开发者

Display octothorpe inside cfoutput tags

开发者 https://www.devze.com 2022-12-21 01:57 出处:网络
<cfoutput query=\"getGames\"> <li> <a href=\"#li开发者_C百科nk_url#\" style=\"background: #E97B2A; display: block; height: 320px; width: 500px;\">#name#</a>
<cfoutput query="getGames">
<li>
<a href="#li开发者_C百科nk_url#" style="background: #E97B2A; display: block; height: 320px; width: 500px;">#name#</a>
</li>
</cfoutput>

the background color # is breaking it, how can I display the # without closing the cfoutput tag (or using css rgb() )?


The # symbol can be escaped within cfoutput tags and in other areas such as strings by doubling it up like ##.

So you need to use the following code:

<cfoutput query="getGames">
<li>
<a href="#link_url#" style="background: ##E97B2A; display: block; height: 320px; width: 500px;">#name#</a>
</li>
</cfoutput>


Loftx's answer will work perfectly. But another option is to move the CSS styling to a .css file or to a style area of your page that sits outside of your cfoutput tags.

<!--- outside the cfoutput you can use single # characters --->
<style type="text/css">
.mystyle { background: #E97B2A; display: block; height: 320px; width: 500px; }
</style>

<!--- inside the cfoutput, # characters must be paired up. --->
<cfoutput query="getGames">
    <li>
        <a href="#link_url#" class="mystyle">#name#</a>
    </li>
</cfoutput>
0

精彩评论

暂无评论...
验证码 换一张
取 消