4

I'm trying to set a div height to 10% (height: 10%; )

It works perfectly in Chrome, but in Edge, the height screws up and appears way shorter than expected (like 1%).

It seems that if I give it a px value (50px) it works on both browsers, but that's not what I'm looking for. I'm using Bootstrap, although I don't think that's a problem.

Is there any other way to fix this than specifically setting a fixed value for Edge in the CSS?

This was the most I could reduce the files in order to reproduce the problem:

<head>
  <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <link rel="stylesheet" type="text/css" href="index.css">
</head>
<body>
  <div class="container">
    <div class="grid">

      <div class="col1">

        <div class="col1content">
          <div class="col1title">
            Connected users
          </div>
          <div class="nameform">
            <form action="">
              <div class="col-md-9 inputdiv">
                <input class="nameinput" placeholder="What's your name?" />
              </div>
              <div class="col-md-3 btndiv">
                <button class="btn btn-success namebtn" type="button">OK</button>
              </div>
            </form>
          </div>

        </div>
      </div>
      <div class="col2" id="chatbox">
            <div class="chat" id="chat">Welcome.</div>
            <div class="msgbox" id="msgbox">
              <form id="chatform" action="">
                <input class="writebox" id="msg" placeholder="Type your message here..." autocomplete="off">
                <button class="btn btn-primary chatbtn" id="chatbutton" type="button">Send</button>
              </form>
            </div>

      </div>

    </div>
  </div>
</body>
body, html {
  height: 100%;
}


.grid {
  display: flex;
  flex-flow: row;
  height: 83%;
  position: relative;
  width: 100%;
  margin:5px;
}
.col1 {
  position: relative;
  background-color: #f2efe8;
  width:50%;
  height: 100%;
  float: left;
  margin-right: 5px;
  font-family: "Segoe UI";

}
.col1content {
  margin: 5px 10px;
}

.nameform {
  position: absolute;
  bottom: 5;
  right: 5;
  height: 10%;
}
.nameinput {
  height:100%;
  max-width: 100%;
  width: 100%;
}
.inputdiv {
  padding-right: 5px;
  padding-left: 5px;
}
.btndiv {
  padding-right: 5px;
  padding-left: 2.5px;
  height: 100%;
}
.namebtn {
  max-width: 100%;
  width: 100%;
  height: 100%;
}
.col2{
  position: relative;
  background-color: #1d2120;
  width:100%;
  float: right;
  margin-left: 5px;
  color: white;
  font-family: "Segoe UI";
  border: medium solid #1d2120;

}
.chat {
width:100%;
height:87%;
overflow:auto;

}
.msgbox {
height:10%;
  display:block;
  background-color:#ffffff;
  height: 10%;
  width:100%;
  position:absolute;
  bottom: 0;
  color: #000000;
  border-radius: 2px;
}

.chatbtn {
  position: absolute;
  top: 1;
  right: 2;
  bottom: 1;
  width: 15%;
  display: inline-block;
}

.writebox {
  background: transparent;
  display:inline-block;
  border: 0;
  height:100%;
  width: 83%;
  margin-left: 5;
}

.separator{
    position:absolute;
    left:34%;
    top:25%;
    bottom:10%;
    height: 70%;
    border-left:1px solid #8c8b8b;
}

.container {
  display: flex;
  align-items: stretch;
  flex-flow: column;
  background-color: #feffff;
  border-radius: 10px;
  box-shadow: 0px 0px 10px black;
  position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    width: 70%;
    height: 70%;
    margin: auto;

}

centered {
  display: flex;
  justify-content: center;
}

Example here: Fiddle

Nicolás de Ory
  • 614
  • 9
  • 31
  • Can you outline which element you are talking about? You have a lot of CSS there and numerous `height:10%` entities. Pick one. And tell us which one and delete CSS that is unneeded for this example. Makes it much easier to read and understand your code. – Martin Apr 29 '17 at 13:37
  • [This answer](http://stackoverflow.com/questions/13545947/position-absolute-and-parent-height) might help you, too – Martin Apr 29 '17 at 13:38
  • @Martin Yes, forgot. It's .nameform. I can't delete most CSS because if I delete the grids, the problem goes away (you wouldn't be able to see it). – Nicolás de Ory Apr 29 '17 at 13:56

1 Answers1

2

Try to be more specific But if you want to set the div 10percnet of viewport this might help
height:10vh;

Discussed here in detail Make div 100% height of browser window

Community
  • 1
  • 1
Amir Shahbabaie
  • 1,352
  • 2
  • 14
  • 33