我试图将div高度设置为10%(高度:10%;)
它在Chrome中完美运行,但在Edge中,高度上升并且看起来比预期的短(比如1%)。
似乎如果我给它一个px值(50px)它适用于两种浏览器,但这不是我想要的。 我使用的是Bootstrap,虽然我不认为这是一个问题。
除了在CSS中专门为Edge设置固定值之外,还有其他方法可以解决这个问题吗?
这是我可以减少文件以便重现问题的最多因素:
<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;
}
此处示例:Fiddle
答案 0 :(得分:1)
尝试更具体 但是如果你想设置视口的div 10percnet,这可能会有所帮助 高度:10vh;