Chrome and safari 100% high

Chrome is OK, Safari is crashing. How can it be compatible?height:100%;

I need to save Chrome and use Safari. My version of Safari is 10.1.2 (12603.3.8)

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  outline: none;
}

* ::-webkit-scrollbar {
  width: 0;
}

html, body {
  height: 100%;
  width: 100%;
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  flex-direction: column;
}

body {
  border: 5px solid red;
}

.d {
  height: 100%;
  border: 5px solid green;
}
<div class="d"></div>
<div class="d"></div>
Run codeHide result

enter image description here

+4
source share
1 answer

Looks like a recent Safari rendering error including flex-direction: column. You put two elements height: 100%in the same space, and both of them are rendering at a height of 100% and styling instead of being embedded in the same space.

Here are two solutions:

  • Change height: 100%to height: 50%so that both elements are half the height of their parent or ...

  • height flex: 1, , , 50/50.

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  outline: none;
}

*::-webkit-scrollbar {
  width: 0;
}

html,
body {
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
}

body {
  border: 5px solid red;
}

.d {
  height: 50%;
  border: 5px solid green;
}
<div class="d"></div>
<div class="d"></div>
Hide result

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  outline: none;
}

*::-webkit-scrollbar {
  width: 0;
}

html,
body {
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
}

body {
  border: 5px solid red;
}

.d {
  flex: 1;
  border: 5px solid green;
}
<div class="d"></div>
<div class="d"></div>
Hide result
0

Source: https://habr.com/ru/post/1683903/


All Articles