如何单独的设置RadioButtonList1的CSS

yangzong20 2011-01-10 10:20:07
我想把单独RadioButtonList1设置一个CSS,我想把它的字体设置成30号字并且是粗体,改如何写这个CSS,麻烦告知谢谢!(我只想这个CSS只对RadioButtonList1有效,对其它的都无效)
...全文
158 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
孟子E章 2011-01-13
  • 打赏
  • 举报
回复
RepeatLayout="Flow"

定义方法
.yzlD5
{
font-size: 36px;
font-family: 新宋体;
color: Red;
}
孟子E章 2011-01-13
  • 打赏
  • 举报
回复
<%@ Page Language="C#" EnableViewState="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

protected void Page_Load(object sender, EventArgs e)
{

}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<style>
TD
{
font-size: 14px;
font-family: MS Shell Dlg,Tahoma,sans-serif,宋体;
}

.yzlD5
{
font-size: 36px;
font-family: 新宋体;
color: Red;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<table border="1">
<tr>
<td>
<asp:RadioButtonList ID="RadioButtonList1" runat="server" CssClass="yzlD5" RepeatLayout="Flow">
<asp:ListItem>aaaaa</asp:ListItem>
<asp:ListItem>aaaaa</asp:ListItem>
</asp:RadioButtonList>
</td>
<td>
aaaaa
</td>
</tr>
</table>

</form>
</body>
</html>
孟子E章 2011-01-13
  • 打赏
  • 举报
回复
<%@ Page Language="C#" EnableViewState="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">

protected void Page_Load(object sender, EventArgs e)
{

}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<style>
TD
{
font-size: 14px;
font-family: MS Shell Dlg,Tahoma,sans-serif,宋体;
}

.yzlD5 label
{
font-size: 36px;
font-family: 新宋体;
color: Red;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<table border="1">
<tr>
<td>
<asp:RadioButtonList ID="RadioButtonList1" runat="server" CssClass="yzlD5" RepeatLayout="Flow">
<asp:ListItem>aaaaa</asp:ListItem>
<asp:ListItem>aaaaa</asp:ListItem>
</asp:RadioButtonList>
</td>
<td>
aaaaa
</td>
</tr>
</table>

</form>
</body>
</html>
yangzong20 2011-01-13
  • 打赏
  • 举报
回复
to net_lover

TD {
FONT-SIZE: 14px; FONT-FAMILY: MS Shell Dlg,Tahoma,sans-serif,宋体
}

TD.yzlD5 {
FONT-SIZE: 18px;FONT-FAMILY: 新宋体
}

asp:RadioButtonList ID="RadioButtonList1" runat="server" CssClass="yzlD5" RepeatLayout="Flow">

还是不行,麻烦看看谢谢
孟子E章 2011-01-13
  • 打赏
  • 举报
回复
你也可以这样

.yzlD5 label
{
font-size: 36px;
font-family: 新宋体;
color: Red;
}

然后
<asp:RadioButtonList ID="RadioButtonList1" runat="server" CssClass="yzlD5">
孟子E章 2011-01-13
  • 打赏
  • 举报
回复
原因是这样的

默认情况下,生成的代码是这样的

<table id="RadioButtonList1" class="yzlD5">
<tr>
<td><input id="RadioButtonList1_0" type="radio" name="RadioButtonList1" value="aaaaa" /><label for="RadioButtonList1_0">aaaaa</label></td>

</tr><tr>
<td><input id="RadioButtonList1_1" type="radio" name="RadioButtonList1" value="aaaaa" /><label for="RadioButtonList1_1">aaaaa</label></td>
</tr>
</table>


所以,td的样式有更高的优先权起作用。所以要去掉默认的方法
孟子E章 2011-01-13
  • 打赏
  • 举报
回复
<asp:RadioButtonList ID="RadioButtonList1" runat="server" CssClass="yzlD5"
RepeatLayout="Flow">

注意
RepeatLayout
yangzong20 2011-01-13
  • 打赏
  • 举报
回复
to net_lover

TD {
FONT-SIZE: 14px; FONT-FAMILY: MS Shell Dlg,Tahoma,sans-serif,宋体
}

TD.yzlD5 {
FONT-SIZE: 18px;FONT-FAMILY: 新宋体
}

asp:RadioButtonList ID="RadioButtonList1" runat="server" CssClass="yzlD5">
我按上面这样做还是不行,麻烦再帮看看谢谢
孟子E章 2011-01-13
  • 打赏
  • 举报
回复
TD.yzlD5{FONT-SIZE: 18px;}

这样呢
孟子E章 2011-01-13
  • 打赏
  • 举报
回复
<asp:RadioButtonList ID="RadioButtonList1" runat="server" CssClass="yzlD5">
yangzong20 2011-01-13
  • 打赏
  • 举报
回复
现在出现了一个问题,我在CSS定义了


TD {
FONT-SIZE: 14px; FONT-FAMILY: MS Shell Dlg,Tahoma,sans-serif,宋体
}

.yzlD5 {
FONT-SIZE: 18px;FONT-FAMILY: 新宋体
}

因为我的RadioButtonList1是放在TD里的,所以只有TD这个对它有效,而yzlD5对它无效,这个该如何解决呢?(我已将CssClass="yzlD5"了还是无效,只有把TD去掉后这个yzlD5才有效)
孟子E章 2011-01-13
  • 打赏
  • 举报
回复
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style>
.c{font-size:24px}
</style>
</head>
<body>
<form id="form1" runat="server">

<asp:RadioButtonList ID="RadioButtonList1" runat="server" CssClass="c">
<asp:ListItem>a</asp:ListItem>
<asp:ListItem>b</asp:ListItem>
</asp:RadioButtonList>

</form>
</body>
</html>
yangzong20 2011-01-13
  • 打赏
  • 举报
回复
如果设置RadioButtonList1他自身的style那么如果把字体放大或缩小它也会跟着放大缩小,我想用CSS来固定住它,不让它变化,但这个CSS只能对这个RadioButtonList1有效,该如何写呢?麻烦告知谢谢!
kevin_520_kevin 2011-01-10
  • 打赏
  • 举报
回复
直接设置他的style应该是可以的啊
wsbgy 2011-01-10
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 wuyq11 的回复:]
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem Value="男"> </asp:ListItem>
<asp:ListItem Value="女"> </asp:ListItem>
</asp:RadioButtonList>
设置RadioButtonList1样式就可……
[/Quote]
顶!!!
wuyq11 2011-01-10
  • 打赏
  • 举报
回复
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem Value="男"> </asp:ListItem>
<asp:ListItem Value="女"> </asp:ListItem>
</asp:RadioButtonList>
设置RadioButtonList1样式就可
<style>
.ListControlCSS {}{ list-style:none; margin:0px; width: 400px; background-color: #CCC; }
.ListControlCSS INPUT {}{ background-color: #CCC; }
.ListControlCSS li{}{ float:left; width:100px; line-height:30px;}
</style>
CssClass="ListControlCSS">
或自定义RadioButtonList
liulang457 2011-01-10
  • 打赏
  • 举报
回复
style属性

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧