Nesting CSS classes and tags

Asked

Viewed 612 times

0

I’m developing a site, Administrative side, already set up Masterpage and now defining the Layout of the pages daughters, where I came across a problem, which I need help. This is the code that matters on the daughter page:

<asp:Content ID="ContentFormAdmin" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div id="FormAdminBase" class="container">
        <div class="row">
            <header id="HeaderFormAdmin">
                <h2>Cadastro dos Serviços Prestados</h2>
            </header>
        </div>
    </div>
</asp:Content>

So I created the CSS as follows:

#FormAdminBase {
    background-color: #285ce6;
    max-width: 1170px;
    margin-left: auto;
    margin-right: auto;
    margin-top: 5px;
    margin-bottom: 3px;
    text-align: center;
    font-size: 18px;
    color: whitesmoke;
    padding: 15px;
    height: calc(100% - 5px);
    border: 3px red ridge;
}

#FormAdminBase h2 {
    text-align: left;
    color: white;
    text-shadow: 4px 4px 5px rgba(31, 54, 99, 0.73);    
}

The thing is that "Registration of Services Provided" is aligned to the left of the browser and not to the left, inside the "Formadminbase" as I imagined you would be. I wonder how to nestle everything in "Formadminbase".

I’m using ASPX, C#, with Bootstrap!

I’ve researched about and I can’t find anything targeted!

  • In case it is positioned outside the parent element? Can you add a print how it looks?

  • I have separated these styles and HTML to a static html, and it is inside the parent element normally. Probably some parent of #FormAdminBase must be affecting the style of <h2>... try to see, in the developer tools of Chrome or Firefox, what is the "computed" style of the element.

1 answer

1

Thanks for the help Wtrmute! I did as you instructed and saw that my mistake was using the <header>, so I took him out and put in a div, then worked as expected.

Stayed like this:

<asp:Content ID="ContentFormAdmin" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div id="FormAdminBase" class="container">
        <div class="row">
            <div id="HeaderFormAdmin">
                <h2>Cadastro dos Serviços Prestados</h2>
            </div>
        </div>
    </div>
</asp:Content>

Well, it was this, the header was right, but to be used in Masterpage and not those who inherit it.

Following Anderson’s lead, I want to clarify that header is dealt with in the CSS as follows:

header {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 60px;
}

Thus, when declaring the use on the daughter, would give the error reported initially.

Once again, my thanks! Always learning!

  • It seems to me the same question code. What exactly did you change?

  • Before I had in sequence 2 divs and the header, now I have 3 divs...

  • Ah, now it’s fixed, but it still doesn’t make sense. By default, the element header has the same behavior as div, why did it work for one and the other not? You have some style in CSS that is applied directly to the elements header?

  • So Anderson, after posting, while you were commenting I was changing! good, yes, I have a header treatment, as follows: header { position: Absolute; left: 0; right: 0; top: 0; height: 60px; } me hint from Wtrmute that I found this flaw!

  • Now it makes perfect sense. I believe you should include this in the answer to make it clear what the actual problem was.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.