0

style.css(only part of code)

header {
    margin-top : 0;
    margin-left:0;
    min-width: 15vw;
    z-index: 50;
    width: 100%;
    height: 5vw;
    font-family: 'Indie Flower', cursive;
    color: wheat;
    text-align: center;
    font-size: 2vw;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

index.html(only part of code.)

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link rel = "stylesheet" href = "style.css">
    <script defer src = "app.js"></script>
    <title>Document</title>
</head>

<body>
    <header style="background-color:#463830; ">
        hello
    </header>
</body>

in mobile devices, the header's width isn't wide enough to fill the whole screen. Any ideas why? I tried different solutions from different stack overflow questions.

casraf
  • 19,496
  • 7
  • 52
  • 86
jkimishere
  • 87
  • 1
  • 3

2 Answers2

0

Here you go... Most browsers will display the <body> element with the following default values (source):

body {
  display: block;
  margin: 8px;
}

body:focus {
  outline: none;
}

You need to override the default margin value by adding this to your CSS:

html,
body {
  margin: 0;
}

See the snippet below.

html,
body {
  margin: 0;
}

header {
  margin-top: 0;
  margin-left: 0;
  min-width: 15vw;
  z-index: 50;
  width: 100%;
  height: 5vw;
  font-family: 'Indie Flower', cursive;
  color: wheat;
  text-align: center;
  font-size: 2vw;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
}
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <link rel="stylesheet" href="style.css">
  <script defer src="app.js"></script>
  <title>Document</title>
</head>

<body>
  <header style="background-color:#463830; ">
    hello
  </header>
</body>
Cervus camelopardalis
  • 2,947
  • 1
  • 5
  • 16
0

Add

*{
   margin = 0;
   padding = 0;
   }

in your code and in the header section

header {

    min-width: 15vw;
    z-index: 50;
    max-width: 100vw;
    width: 100%;
    height: 5vw;
    font-family: 'Indie Flower', cursive;
    color: wheat;
    text-align: center;
    font-size: 2vw;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

apply this code snippet, hope this works!