I am trying to prevent the header element from scrolling, so I gave it position: fixed but that changes it size as per the second image below.
I am after a css to maintain the look of the first image and prevent the header from scrolling. Thanks

html, body {
    height: 100%;
    padding: 0;
    margin: 0;
}
button {
    height: 1.5em;
    width: 1.5em;
    font-size: 1.5em;
    top: 0;
}
label {
    display: inline-block;
    width: calc(100% - 5em);
    text-align: center;
}
header {
    border-bottom: 1px solid black;
    background-color: yellow;
    position: fixed;
}
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="index.css">
    <meta name="viewport" content="width=device-width" />
</head>
<body >
<header>
    <button class="menuLeft" type="button" >☰</button>
    <label>Title of Page</label>
    <button class="menuRight" type="button">⋮</button>
</header>
</body>
</html>
Just give width:100% to header.
html, body {
    height: 100%;
    padding: 0;
    margin: 0;
}
button {
    height: 1.5em;
    width: 1.5em;
    font-size: 1.5em;
    top: 0;
}
label {
    display: inline-block;
    width: calc(100% - 5em);
    text-align: center;
}
header {
    border-bottom: 1px solid black;
    background-color: yellow;
    position: fixed;
  width: 100%;
}
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="index.css">
    <meta name="viewport" content="width=device-width" />
</head>
<body >
<header>
    <button class="menuLeft" type="button" >☰</button>
    <label>Title of Page</label>
    <button class="menuRight" type="button">⋮</button>
</header>
</body>
</html>
Simply add width:100%; to the header, like the following solution:
html, body {
  height: 100%;
  padding: 0;
  margin: 0;
}
button {
  height: 1.5em;
  width: 1.5em;
  font-size: 1.5em;
  top: 0;
}
label {
  display: inline-block;
  width: calc(100% - 5em);
  text-align: center;
}
header {
  border-bottom: 1px solid black;
  background-color: yellow;
  position: fixed;
  width:100%;
}
<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link rel="stylesheet" href="index.css">
    <meta name="viewport" content="width=device-width" />
  </head>
  <body >
    <header>
      <button class="menuLeft" type="button" >☰</button>
      <label>Title of Page</label>
      <button class="menuRight" type="button">⋮</button>
    </header>
  </body>
</html>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With