1

Sorry if this is a basic question but here is my code: http://jsfiddle.net/s7wdkxun/

I can't understand why this isn't working with the percentage widths, instead it stays as fixed pixels.

<div style="width: 100%">
    <input class="1">
    <input class="2">
    <input class="3">
</div>

CSS

* {
    margin: 0;
    padding: 0
}
.1 {
    width: 30%;
    margin-right: 10%
}
.2 {
    width: 30%;
    margin-right: 10%
}
.3 {
    width: 20%
}

Where am I going wrong?

J.Zil
  • 2,397
  • 7
  • 44
  • 78

5 Answers5

4

CSS classes cannot start with a number, per W3 spec. Change it's name and it should work.

http://www.w3.org/TR/CSS21/grammar.html

BReal14
  • 1,603
  • 1
  • 12
  • 35
2

not have to do with numbers
Do NOT start an SELECTOR with a number!

use:

<input class="one">
<input class="two">
<input class="tree">
alessandrio
  • 4,282
  • 2
  • 29
  • 40
2

As explained here Which characters are valid in CSS class names/selectors?:

...a name must begin with an underscore (_), a hyphen (-), or a letter(a–z), followed by any number of hyphens, underscores, letters, or numbers. There is a catch: if the first character is a hyphen, the second character must be a letter or underscore, and the name must be at least 2 characters long.

So if you update your class names to meet this criteria, for example change to one, two, and three it will work properly. JS Fiddle Demo

Community
  • 1
  • 1
Dan
  • 9,391
  • 5
  • 41
  • 73
1

you can't have a class name that starts with a number... try input1 instead of 1

Gho
  • 570
  • 2
  • 9
1

You can't use classes that starts with digits. Try to give them string names

Anton
  • 2,217
  • 3
  • 21
  • 34