remove / reset inherited css from an element

前端 未结 9 1316
攒了一身酷
攒了一身酷 2020-12-06 04:00

I know this question was asked before, but before marking it as a duplicate, I want to tell you that my situation is a little different from what I found on the internet.

9条回答
  •  眼角桃花
    2020-12-06 04:30

    Try this: Create a plain div without any style or content outside of the red div. Now you can use a loop over all styles of the plain div and assign then to your inner div to reset all styles.

    Of course this doesn't work if someone assigns styles to all divs (i.e. without using a class. CSS would be div { ... }).

    The usual solution for problems like this is to give your div a distinct class. That way, web designers of the sites can adjust the styling of your div to fit into the rest of the design.

提交回复
热议问题