Customize an item within css for a particular view

Asked

Viewed 339 times

0

I have this view on MVC

View

@model XXX
@{

}

<link href="/eTeste/Content/AbaDetailsODM.css" rel="stylesheet" type="text/css" />

<div id="consoleAbaDetalhes"></div>

<div id="campos_detail">
    @using (Ajax.BeginForm(
        "xxxx",
        "xxxx",
        new AjaxOptions
        {
            InsertionMode = InsertionMode.Replace,
            UpdateTargetId = "consoleAba",
            HttpMethod = "POST",

        }))
    {
        @Html.Partial("Validation")
        @Html.HiddenFor(i => i.Id)
        @Html.HiddenFor(i => i.IdEmpresa)
        @Html.HiddenFor(i => i.IdModeloVersao)
        [...]

        <div id="campos">
            <div class="CampoRealyOnly">
                @Html.EditorFor(i => i.User)
                <div class="clear"></div>
                @Html.EditorFor(i => i.Gerente)
                <div class="clear"></div>
                <div id="chefesDeProjeto">
                @Html.EditorFor(i => i.Descricao, "TextArea", new { colunas = 30, linhas = 5 })
                </div>

            </div>

            <div class="CampoRealyOnly clear field-middle">

            <h3>@Html.Label(ODMResources.AreaLeader):</h3>
                @Html.TextBoxFor(x => x.ResponsaveisFuncao)
            </div>
            [...] //Vários Campos
        </div>

The system has its own field CSS.
I would like to change a part of this CSS, just for this View.
This part is Energy of the system.

The css works as I would like, the problem is that it alters all the other tabs, even though I only referenced it in this view. I believe it is the cascade mode that causes it to be changed in everything.

What could I do to separate it from the system?

CSS

.CampoRealyOnly
input[type=text], textarea, select
{
    border: 1px solid #888888;
    left: 298px;
    position: relative;
    top: -29px;
}
h3
{
    color: Red;
}
  • Let me get this straight. You have a view that contains x fields that you want to be visually different from the fields outside of it (in _layout) for example?

2 answers

0

You have to use your own class, preferably extending generic selectors, in your case input[type=text], textarea, select etc....

If you would like to change the style of a specific tab, create a specific class for this tab, so you know what it’s about, for example:

input[type=text].nomeAba{
  seu estilo aqui
}

now just wrap your tab inside the class nomeAba, may be a div

Notice that I mentioned the word "specific," which gets into this subject: Specifics On Css Specificity where you will find references that help you.

0


I had to create selectors for my own class. In the end it was like this:

.CampoRealyOnly input[type=text], .CampoRealyOnly textarea, .CampoRealyOnly select
{
    border: 1px solid #888888;
    left: 298px;
    position: relative;
    top: -29px;
}
  • In this case I believe that the answer of @Danielgroh is correct, because he gave you this tip. Anyway don’t forget to accept an answer to your question.

  • I’m sorry, but I saw it somewhere before!

  • Then accept your answer as the correct one

Browser other questions tagged

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