0

I want a box that has margin. But position fixed don't seems to contain in my App class?

   <div className="App">
      <div className="box">
      <h1>Hello CodeSandbox</h1>
      <h2>Start editing to see some magic happen!</h2>
      </div>
    </div>


.box {
  position: fixed;
  background: red;
  width: 100%;
  box-sizing: border-box;
  height: 100%;
}

https://codesandbox.io/s/affectionate-benz-93zp3z?file=/src/App.js

is there any other way to achieve full screen with margin except with fixed?

Fay Chen
  • 521
  • 1
  • 4
  • 12

1 Answers1

0

I'm struggling to understand your question, but it appears as if you're struggling with applying a margin to your .box. You can not apply a margin to a fixed element. Source: Why isn't my margin working with position: fixed?

Harley Swift
  • 172
  • 1
  • 11