skip to Main Content

enter image description here

The white box with the cut off form to the left is the background here.

I temporarily took out all other styling and this is all that is left (some of it is not mine):

body {
    margin: 0;
    font-family: -apple-system, Arial, sans-serif;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #69ce16;
    text-align: left;
    background-color: #fff;
    background-position: center;
    background-size: 20%;
    background-repeat: no-repeat;
    padding: 30px;
    padding-bottom: 10px;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    width: 50%;
}

I added the background size, repeat and position myself and even tried adjusting every other value there but nothing has worked. I used developer.mozilla.org for info on every single one of those css properties, so I have no idea why it won’t center to the middle of that "grey" page, or anywhere I want it, and even trying to reduce its size/width has not worked.

2

Answers


  1. Try changing your width for example to

    body{
       ...
       width: 50%;
       /* maybe add some height? */
       height: 500px;
    }
    

    Then you will see a change

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
    </head>
    <body>
        <style>
        body {
        margin: 0;
        font-family: -apple-system, Arial, sans-serif;
        font-size: 1rem;
        font-weight: 400;
        line-height: 1.5;
        color: #69ce16;
        text-align: left;
        background-color: white;
        background-position: center;
        background-size: 20%;
        background-repeat: no-repeat;
        padding: 30px;
        padding-bottom: 10px;
        border: 1px solid #ced4da;
        border-radius: 0.25rem;
        width: 80%;
        height:200px;
    }</style>
    </body>
    </html>
    Login or Signup to reply.
  2. Did you even read the css you have?

    border: 1px solid #ced4da;
    width: 50%;
    

    you most certainly wouldn’t wanna add paddings text-align, color on body…

    anyways.

    If you clean the body and html in your css, and add a wrapper div on the form you want with some css like this

    .form-wrapper{
         background-color: red;
         margin: auto;
         width: 50%;
         border: 1px solid #ced4da;
         border-radius: 0.25rem;
    }
    

    It would achieve the look you want. I would suggest you take a look at css docs

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search