0

I want this css code to work:

#inventoryGarbageSpot .id1,.id2,id3,id4{
padding:0px;
padding-top: 0px;
width:35px;}

If I write one id instead of multiple ids it works.

Thanks for your help,

Rotem

2 Answers 2

2

If we decompose your selector, you're targeting :

  • #inventoryGarbageSpot .id1
  • .id2
  • id3
  • id4

First, there're 2 non-existent elements : id3 and id4, which will stand for this kind of elements :

<id3></id3>
<id4></id4>

Secondly, you need to repeat your #inventoryGarbageSpot before each class.

Instead of this unefective selector, use this one :

#inventoryGarbageSpot .id1,
#inventoryGarbageSpot .id2,
#inventoryGarbageSpot .id3,
#inventoryGarbageSpot .id4 {
    padding:0px;
    padding-top: 0px;
    width:35px;
}

If you want to generalize your selector, you can use an attribute selector, as mentioned by Sudharsan.

Sign up to request clarification or add additional context in comments.

Comments

1

Use attribute selector like this

style be

  #inventoryGarbageSpot [class^="id"]{
    padding:0px;
    padding-top: 0px;
    width:35px;
    }

that should be

[class^="id"]{

   // here style

}

4 Comments

Can you write your code with the example of "id1,id2,id3,id4" please
I still cant understand where to put the ".id1,.id2,.id3,.id4" :(
you want static ids like id1, id2 to id4 follow zessex answer. if you want dynamic means follow my answer thanks
please put the code in your css file it will work don't worry first try

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.