如何将跨度的背景颜色设置为外部div?

时间:2016-02-01 06:54:11

标签: html css

我希望重置密码的背景颜色为外部div的最大宽度。背景颜色必须是标题部分的全宽。如何做?

HTML:

<div class="forgot-inner">
            <!--Forgot-header-->
                    <div class="forgot-header">
                        <div class="header">
                        <span>Reset Password</p>
                        </div>
                    </div>
</div>

的CSS:

        .forgot-inner {
        max-width: 331px;
        margin: 39px auto;
        padding: 13px 24px;
        background: #fff;
        text-align: center;
        border: 1px solid #aaa;
        border-radius: 4px;
        box-shadow: 2px 11px 31px 2px rgba(0,0,0,0.2);
    }

    .forgot-inner .forgot-header .header{
        border-bottom:1px solid #aaa;
        text-align:left;
        background-color:#edefed;
        width:100% !important;
        font-size: 14px;
        font-weight: bold;
    }    

This is how it looks

2 个答案:

答案 0 :(得分:0)

&#13;
&#13;
 .forgot-inner {
        max-width: 331px;
        margin: 39px auto;
        padding: 13px 24px;
        background: #fff;
        text-align: center;
        border: 1px solid #aaa;
        border-radius: 4px;
        box-shadow: 2px 11px 31px 2px rgba(0,0,0,0.2);
    }

    .forgot-inner .forgot-header .header{
        border-bottom:1px solid #aaa;
        text-align:left;
       
        width:100% !important;
        font-size: 14px;
        font-weight: bold;
    }  

 .forgot-inner .forgot-header .header span{background-color:#edefed;}
&#13;
<div class="forgot-inner">
            <!--Forgot-header-->
                    <div class="forgot-header">
                        <div class="header">
                        <span>Reset Password</p>
                        </div>
                    </div>
</div>

       
&#13;
&#13;
&#13;

答案 1 :(得分:0)

你可以试试这个:

margin: -13px -24px;