How can I select this item?

I have code blindness, it looks like blindness, just too much code.

I have a dynamic div class,

<div class="even last"> 

      

How can I select this with CSS?

div.even last {
    background-color:#ffffff;
    height:100%;
    border-top:1px solid #F5F5F5;
    padding:2px;
    margin-top:35px;
}

      

It doesn't seem to work and I just can't think anymore.

Thanks:)

+2


a source to share


4 answers


When multiple classes are specified with a space, it applies both of these elements to the element.



So if you specify div.even

AND / OR div.last

, it will use them.

+7


a source


You cannot have spaces in the css class name. This should work:

<div class="even_last"> 

div.even_last {
    background-color:#ffffff;
    height:100%;
    border-top:1px solid #F5F5F5;
    padding:2px;
    margin-top:35px;
}

      

Spaces in css means the next element contained in the previous one, for example:



<div class="even_last">
    <div>
        Hello
    </div>
    World
</div>

div.even_last div {
    font-weight:bold;
}

      

Hello will be brave, but the world will not.

+4


a source


Replace the space with a dot and you're right:

div.even.last {
    background-color:#ffffff;
    height:100%;
    border-top:1px solid #F5F5F5;
    padding:2px;
    margin-top:35px;
}

      

+3


a source


Name your class like evenlast

:

div.evenlast
{
  /* styles here */
}

      

0


a source







All Articles