如何把 DropDownList 某一个 Item 的 Text 改成粗体 ?

这是昨天 CSDN 里面的一个帖子 

http://community.csdn.net/Expert/TopicView3.asp?id=5637788

今天发现竟然成为头条了。

本以为,可以像设置字体颜色一样设置字形,结果大出意料,只有 FF 才可以呈现出预期的效果。

测试代码:

ExpandedBlockStart.gif ContractedBlock.gif <% dot.gif @ Page Language="C#"  %>
None.gif
None.gif
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
None.gif
ExpandedBlockStart.gifContractedBlock.gif
< script  runat ="server" > dot.gif
InBlock.gif
InBlock.gif    protected 
void Page_Load(object sender, EventArgs e)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        ListItem item 
= null;
InBlock.gif        item 
= new ListItem("Red--Setting by code-programming""red");        
InBlock.gif        item.Attributes[
"style"= "color: " + item.Value;
InBlock.gif        DropDownList1.Items.Add(item);
InBlock.gif
InBlock.gif        item 
= new ListItem("Bold Font?--Setting by code-programming""bold");
InBlock.gif        item.Attributes[
"style"= "font-weight:" + item.Value;
InBlock.gif        DropDownList1.Items.Add(item);
InBlock.gif        
InBlock.gif        item 
= new ListItem("none");
InBlock.gif        DropDownList1.Items.Add(item);
ExpandedBlockEnd.gif    }

None.gif
</ script >
None.gif
None.gif
< html  xmlns ="http://www.w3.org/1999/xhtml"   >
None.gif
< head  runat ="server" >
None.gif    
< title > ListItemStyle_FontWeight_Test </ title >
None.gif
</ head >
None.gif
< body >
None.gif    
< form  id ="form1"  runat ="server" >
None.gif    
< div >
None.gif        
< asp:DropDownList  ID ="DropDownList1"  runat ="server" >         
None.gif        
< asp:ListItem  style ="color:green" > Green--Setting by declarative-style </ asp:ListItem >
None.gif        
< asp:ListItem  style ="font-weight:bold" > Blod Font?----Setting by declarative-style </ asp:ListItem >
None.gif        
</ asp:DropDownList ></ div >
None.gif    
</ form >
None.gif
</ body >
None.gif
</ html >
None.gif

效果:




只有 FF 最感冒了, 但是当选中某一项后,颜色恢复到整个 select 的设置。

转载于:https://www.cnblogs.com/Jinglecat/archive/2007/07/06/809157.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值