Counting from the center (so, from the right with heroes, and left with monsters) heroes/monsters occupy the position they are in, starting from 1. Some large monsters may take 2 positions at once.
There may be empty positions. All empty positions are always in the back. If an empty position would be created in the middle of the line of enemies/monsters, the back of the line moves forward to fill the space.
There may be things that fill up a space, like corpses, barricades or other oddities, but those pretty much count as weird kind of enemies.
If a skill targets an empty position, nothing happens.
Got a skill that hits position 4, but there isn't a monster there? Tought luck.
Trying to hit positions 2 and 3, when monsters are at positions 1 and 2? You'll only hit positions 2.
Does your last remaining hero only have skills that work from back row? Boy, you are screwed.
This does mean that certain skill loose their effectiveness as you thin the monster ranks, if there are only a few of them in the first place, or if your own party suffers casualities. It is wise to take this in account when selecting your party and their skills.