Add CSS to react created elements like data-reactroot

前端 未结 3 1113
时光说笑
时光说笑 2021-02-04 01:28

Under my root div react creates another div \"automatically\". Is there a way to add a class to that div? I need to add height: 100% to it to prevent the background content to s

相关标签:
3条回答
  • 2021-02-04 01:43

    If you want to use in-line css, just make your top div position is absolute and left, top, right, bottom is zero. So if you inspect the element:

    <div id="root">
      <div data-reactroot>
        <div style="position: absolute; top: 0px; left: 0px; right: 0px; bottom: 0px>
           ....
    
    0 讨论(0)
  • 2021-02-04 01:49

    #root > [data-reactroot] { height: 100% } in your CSS should work.

    Or just the tag itself:

    [data-reactroot] { ... }
    
    0 讨论(0)
  • 2021-02-04 01:51

    So simple by using the id reference

    #root{
      /* your css here! */ 
    }
    
    0 讨论(0)
提交回复
热议问题