C# 如何将css输入应用到最后一个子级?

C# 如何将css输入应用到最后一个子级?,c#,html,asp.net,css,webforms,C#,Html,Asp.net,Css,Webforms,对不起,如果我的帖子重复。我找不到解决问题的办法。我有div标签包括2个aspx按钮。它在运行代码时呈现输入[type=“submit”]标记。第一个输入标记工作正常,最后一个输入标记不能继承css。这是我的密码: ASPX <div class="loginButton"> <div style="float:left; margin-left:-9px;"> <input type="checkbox" id="on_off" name="rem

对不起,如果我的帖子重复。我找不到解决问题的办法。我有div标签包括2个aspx按钮。它在运行代码时呈现输入[type=“submit”]标记。第一个输入标记工作正常,最后一个输入标记不能继承css。这是我的密码:

ASPX

<div class="loginButton">
  <div style="float:left; margin-left:-9px;">
      <input type="checkbox" id="on_off" name="remember" class="on_off_checkbox" value="1" />
      <span class="f_help">Remember me</span>
  </div>
  <div class=" pull-right" style="margin-right:-8px;">
      <div class="btn-group">
        <dx:ASPxButton AutoPostBack="false" ID="but_login" CssClass="btn" Native="true" EnableDefaultAppearance="false" runat="server" Text="Login">
        </dx:ASPxButton>
        <dx:ASPxButton ID="forgetpass" CssClass="btn" Native="true" EnableDefaultAppearance="false" runat="server" Text="Forget Pass"></dx:ASPxButton>
      </div>
  </div>
  <div class="clear"></div>
</div>

那么我的代码有什么问题吗?

CSS中的类与Asp代码中的类不匹配。

试试这个

<style type="text/css">
    .btn-group > .btn:first-child
    {
        margin-left: 0;
        -webkit-border-bottom-left-radius: 6px;
        border-bottom-left-radius: 6px;
        -webkit-border-top-left-radius: 6px;
        border-top-left-radius: 6px;
        -moz-border-radius-bottomleft: 6px;
        -moz-border-radius-topleft: 6px;
    }

    .btn-group > .btn:last-child
    {
        -webkit-border-top-right-radius: 6px;
        border-top-right-radius: 6px;
        -webkit-border-bottom-right-radius: 6px;
        border-bottom-right-radius: 6px;
        -moz-border-radius-topright: 6px;
        -moz-border-radius-bottomright: 6px;
    }
</style>

.btn组>.btn:第一个孩子
{
左边距:0;
-webkit边框左下半径:6px;
边框左下半径:6px;
-webkit边框左上半径:6px;
边框左上半径:6px;
-moz边界半径左下角:6px;
-左上角moz边界半径:6px;
}
.btn组>.btn:最后一个子级
{
-webkit边框右上角半径:6px;
边框右上角半径:6px;
-webkit边框右下半径:6px;
边框右下半径:6px;
-moz边界半径右上角:6px;
-moz边界半径右下角:6px;
}

向第二分区添加一个CssClass,例如

<dx:ASPxButton ID="forgetpass" CssClass="btn newClass" Native="true" EnableDefaultAppearance="false" runat="server" Text="Forget Pass"></dx:ASPxButton>

你可以通过css来遵循这个概念

input[type="checkbox"]:last-child {margin-left:20px;}

input[type="radio"]:last-of-type:checked:after{background-color:#000;}

请关注
:最后一种类型

现在您使用内联样式(这通常不好,随着时间的推移,它可能会降低代码的可读性)。我建议您将所有样式移动到css文件。CssClass=“btn”无大或下拉切换?@Agares我做了,但没有任何更改
.newClass
{
//your code
} 
input[type="checkbox"]:last-child {margin-left:20px;}

input[type="radio"]:last-of-type:checked:after{background-color:#000;}