Skip to content

Instantly share code, notes, and snippets.

@kristoferjoseph
Created May 18, 2017 18:57
Show Gist options
  • Save kristoferjoseph/643e6f00291b60bd7dd9bf33095cb80a to your computer and use it in GitHub Desktop.
Save kristoferjoseph/643e6f00291b60bd7dd9bf33095cb80a to your computer and use it in GitHub Desktop.
Example of a fixed header html page using flexbox
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Fixed header</title>
<style>
.container {
display: flex;
flex-direction: column;
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
height: 100%;
height: 100vh;
}
.header {
flex-grow: 0;
height: 4rem;
min-height: 4rem;
background: black;
}
.content {
flex-grow: 1;
overflow: auto;
}
.footer {
flex-grow: 0;
height: 4rem;
min-height: 4rem;
background: black;
}
</style>
</head>
<body>
<div class="container">
<header class="header">😺</header>
<div class="content">
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>Item 4</li>
<li>Item 5</li>
<li>Item 6</li>
<li>Item 7</li>
<li>Item 8</li>
<li>Item 9</li>
<li>Item 10</li>
<li>Item 11</li>
<li>Item 12</li>
<li>Item 13</li>
<li>Item 14</li>
<li>Item 15</li>
<li>Item 16</li>
<li>Item 17</li>
<li>Item 18</li>
<li>Item 19</li>
<li>Item 20</li>
<li>Item 21</li>
<li>Item 22</li>
<li>Item 23</li>
<li>Item 24</li>
<li>Item 25</li>
<li>Item 26</li>
<li>Item 27</li>
<li>Item 28</li>
<li>Item 29</li>
<li>Item 30</li>
<li>Item 31</li>
<li>Item 32</li>
<li>Item 33</li>
<li>Item 34</li>
<li>Item 35</li>
<li>Item 36</li>
<li>Item 37</li>
<li>Item 38</li>
<li>Item 39</li>
<li>Item 40</li>
<li>Item 41</li>
<li>Item 42</li>
<li>Item 43</li>
<li>Item 44</li>
<li>Item 45</li>
<li>Item 46</li>
<li>Item 47</li>
<li>Item 48</li>
<li>Item 49</li>
<li>Item 50</li>
<li>Item 51</li>
<li>Item 52</li>
<li>Item 53</li>
<li>Item 54</li>
<li>Item 55</li>
<li>Item 56</li>
<li>Item 57</li>
<li>Item 58</li>
<li>Item 59</li>
<li>Item 60</li>
<li>Item 61</li>
<li>Item 62</li>
<li>Item 63</li>
<li>Item 64</li>
<li>Item 65</li>
<li>Item 66</li>
<li>Item 67</li>
<li>Item 68</li>
<li>Item 69</li>
<li>Item 70</li>
<li>Item 71</li>
<li>Item 72</li>
<li>Item 73</li>
<li>Item 74</li>
<li>Item 75</li>
<li>Item 76</li>
<li>Item 77</li>
<li>Item 78</li>
<li>Item 79</li>
<li>Item 80</li>
<li>Item 81</li>
<li>Item 82</li>
<li>Item 83</li>
<li>Item 84</li>
<li>Item 85</li>
<li>Item 86</li>
<li>Item 87</li>
<li>Item 88</li>
<li>Item 89</li>
<li>Item 90</li>
<li>Item 91</li>
<li>Item 92</li>
<li>Item 93</li>
<li>Item 94</li>
<li>Item 95</li>
<li>Item 96</li>
<li>Item 97</li>
<li>Item 98</li>
<li>Item 99</li>
<li>Item 100</li>
</ul>
<footer class="footer">👣</footer>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment