BlackHatSamurai
BlackHatSamurai

Reputation: 23503

Why is my CSS class not working

I have the following HTML:

<div id="main">
    <div id="calendar">
    <div class="column" id="time_slots">
    </div>

        <div class="column" id="day1">
            <div class="route_container">
                <div class="date"></div>
                <button class="add_route" name="add_route" onclick="">Add New Route - 1</button>
                <div class = "truck" id="day1_route1">
                    <div class="8-10">8-10 AM today</div>//want css for this
                    <div class="10-12">10-12 AM</div>
                    <div class="12-2">12-2 AM</div>
                    <div class="2-4">2-4 AM</div>
                    <div class="4-6">4-6 AM</div>
                </div>
            </div>
        </div>
            ...etc...

I then have the following CSS:

.label
{
    width:20px;
}

.table
{
    font-size: 1.2em;
}
#main
{
    border-style: solid;
    border-width: 1px;
    border-color: black; 
    width:97%;
    height:900px;
    margin:auto;
    overflow: auto; 
    white-space: nowrap;

}
h2
{
    font-size: 24px;
}
#calendar
{
    padding:1%;

}
.column
{
    border-style: solid;
    border-width: 1px;
    border-color: black; 
    min-width:10%;
    max-width:100%;
    height:800px;
    display: inline-block;
    overflow: auto;
    padding:5px;
    font-size: 0px;


}
.header
{
    padding:0;
    margin:0;
    text-align: center; 
    font-style: bold; 
}

.truck
{
    width:200px;
    border-style: solid;
    border-width: 1px;
    border-color: black; 
    display:inline-block;
    margin:auto;
    font-size: 16px;


}

.column#time_slots
{
    width:5%;
    min-width:5%;
    max-width: 10%; 
}
.date
{
    text-align: center;
    width:100%;
}
.column button
{
    display:block;
    width:100%;
    width:100%;
    border-style: solid;
    border-width: 1px;
    border-color: black; 
    font-size: 16px; 
}
.full_time
{
    display: none; 
}
.8-10
{
    border-style: solid;
    border-width: 1px;
    border-color: black; 
    width:100px;
    height:18px;

    font-size: 24px;    
}

The issue is that I'm trying to define all the classes for 8-10, 10-12, 12-2, 2-4, & 4-6. I originally tried:

.8-10, .10-12, .12-2, .2-4, .4-6
    {
        border-style: solid;
        border-width: 1px;
        border-color: black; 
        width:100px;
        height:18px;

        font-size: 24px;    
    }

But that didn't work. What am I doing wrong? I can't even get a single class (8-10) to work? How do I fix this?

Upvotes: 0

Views: 3949

Answers (4)

Guffa
Guffa

Reputation: 700790

A class name can start with an underscore, a dash, or a letter, not a digit.

"In CSS, identifiers (including element names, classes, and IDs in selectors) can contain only the characters [a-zA-Z0-9] and ISO 10646 characters U+00A0 and higher, plus the hyphen (-) and the underscore (_); they cannot start with a digit, two hyphens, or a hyphen followed by a digit."

http://www.w3.org/TR/CSS21/syndata.html#characters

Upvotes: 2

nkmol
nkmol

Reputation: 8091

It's your Css selector grammar, you can't start a selector with a number.

Upvotes: 4

DaniP
DaniP

Reputation: 38262

You can't start a name class with numbers you can start it with a letter a-z or underscore _ or -. Check it here http://www.w3.org/TR/CSS21/grammar.html#scanner.

Upvotes: 2

Carl0s1z
Carl0s1z

Reputation: 4723

The reason that it doesn't work, is because you cant use numbers in the beginning of the class name.

Wrong: .123text
Right: .text123

Upvotes: 4

Related Questions