0

I have a UL in which I have 6 LI. I want to set a different width of each LI. I am using server side coding using JSP. I have a variable set which contains an array of 6 numbers. I want to assign those number as width % to the LI elements. The only way I can see doing is :

<li style="width:<c:out value="${number}"/>%;">hello</li>

This seems a bit lame. Is there a way in which I can dynamically set the width of an LI element using JSTL (and no client side tech like javascript / jquery).

Thank you in advance.

4

2 回答 2

1

你可以简单地这样做:

<li style="width:${number}%;">hello</li>

的用法c:out对于转义 XML 很有用,例如,如果number内容是:

<ul></ul>

输出将是

&lt;ul&gt;&lt;/ul&gt;

更多信息 :

于 2013-06-07T18:05:33.807 回答
1

好主意,@Alexandre Lavoie。

就个人而言,服务器端动态 CSS 让我头疼,但你去吧:

<head>
<style>
li
{
width: ${number}
}
</style>
</head>
<body>
<ul>
<li>hello</li>
</ul>
</body>
于 2013-06-07T20:17:28.530 回答