Copy, paste, paste, paste; last iteration isn't conforming

Hi, all,

Have you ever worked diligently to get a layout perfect, then copy and paste that code several times on the same page, giving each element unique IDs only to have the last paste of that code not do exactly what the first three versions are doing?

That’s what I’ve got, right now. Four divs that are all identical (except the IDs of the elements) and the first three are doing exactly what I want, but the fourth one is pushing an input element down one line that the others aren’t doing.

Why does that happen, and how can I fix it?

V/r,

:slight_smile:

And you’re doing it by id why? If you’ve got multiple elements which should be styled the same, why not use classes instead?

As for the discrepancy, use inspect element on that last element and see why it’s styling the others different. Otherwise, post a link or a codepen so we have something to look at…

The coding Gods have deemed the 4th child of every iteration must be deformed.

At least, that’s what my psychic powers are telling me :wink: .

1 Like

I didn’t say that I was styling by id; I’m making SURE they all have unique IDs. And there are classes involved.

As it turns out, one of the issues with having more than one person working on a codebase: developers adding code to CSS files without telling anyone else what or why. In this case, my co-worker added a line to the CSS file SPECIFICALLY FOR THAT LAST ITERATION (I have NO idea why) that makes an input a block-level display.

WTF?

I asked, and even he doesn’t remember why he did that. But I commented out the display:block; line for that element, and it’s fixed. I can start growing my hair back, now.

Banging my head into my desk, repeatedly, sharply.

:slight_smile:

Remedy: Bang developer’s head on desk sharply. Not yours.

3 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.