gpt4 book ai didi

html - Div 不在同一高度

转载 作者:太空宇宙 更新时间:2023-11-04 08:26:59 25 4
gpt4 key购买 nike

我正在尝试获取包含三个 <div> 的页面应该彼此相邻并且在页面底部应该显示第四个 <div> .所有这些都应该在不滚动的情况下可见,这就是为什么我使用 100vh 和 100vw 来仅使用视场。但它把所有三个 <divs>在不同的高度。

它将成为一个 HbbTV 应用程序,这就是为什么全屏很重要。

html,body { margin:0; padding: 0; }
#inputpanel {
width: calc(40vw - 10px);
}
#selectpanel {
width: calc(20vw - 10px);
}
#colorpanel {
width: calc(40vw - 10px);
}
#inputpanel,#selectpanel,#colorpanel {
display: inline-block;
box-sizing: border-box;
height: calc(100vh - 200px);
margin: 0;
padding: 0;
}
.b_footer {
padding: 10px;
height: 200px;
background-color: blue;
text-align: center;
color: white;
font-weight: bold;
box-sizing: border-box;
}
.colorbuttons {
background-color: #0000ff;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
width: 30%;
margin: 10px;

}
<?xml version="1.0" encoding="UTF-8" ?>
<!--As DOCTYPE either the strict XHTML declaration or "-//HbbTV//1.1.1//EN" "http://www.hbbtv.org/dtd/HbbTV-1.1.1.dtd" shall be used as described in the HbbTV-standard: A.2.6.2.-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--Required XML-namespace as described in the HbbTV-standard: A.2.6.2.-->
<html xmlns="http://www.w3.org/1999/xhtml">

<head> <!--Required MIME content type as described in the HbbTV-standard: A.2.6.2.-->
<meta http-equiv="Content-Type" content="application/vnd.hbbtv.xml+xhtml; utf-8" />
<!--script type="text/javascript" src="hueapi.js"/-->
<link rel="stylesheet" href="DemoHbbtvHue.css"/>
<title>Demo for HbbTV and Hue</title>
</head>

<body>

<div id="inputpanel">

Step1: Enter IP or use DummySystem.
<button type="button" id="dummy" onclick="enteringDummySystem()">DummySystem</button><br />
<br />
NOTE: Please press the button on your Hue-Bridge before clicking on "Search"<br />
IP: <input type="text" id="inIP" />
<button type="button" id="buIP" onclick="searchDevices('Lamp', 'Hue', document.getElementById('inIP').value)">Search</button><br />
<button type="button" id="getIds" onclick="getId()">Get Light IDs</button>
<button type="button" id="createBut" onclick="createButton(function(){
alert('it works');})">create Button</button>

</div>

<div id="selectpanel">
gfsd

</div>

<div id="colorpanel">

<button type="button" class="colorbuttons" id="buttonSetColorWhite" onclick="setColor(0.1684,0.0416)">Blue</button><br />
<button type="button" class="colorbuttons" id="buttonSetColorRed" onclick="setColor(0.6549,0.3126)">Red</button><br />
<button type="button" class="colorbuttons" id="buttonSetColorWhite" onclick="setColor()">White</button><br />
<button type="button" class="colorbuttons" id="buttonSetColorRed" onclick="setColor()">Green</button><br />
<button type="button" class="colorbuttons" id="buttonSetColorWhite" onclick="setColor()">Yellow</button><br />
<button type="button" class="colorbuttons" id="buttonSetColorRed" onclick="setColor()">Pink</button><br />

</div>

<div class="b_footer">
This demo provides the possibility to control Philips Hue lamps via a HbbTV-Application.
</div>

</body>

</html>

我可以改变什么来实现我正在寻找的东西?

最佳答案

如果您要做的只是在不滚动的情况下获取视口(viewport)中的所有元素(并使前三个 div 具有相同的高度),您可以添加 overflow: hidden;#inputpanel,#selectpanel,#colorpanel样式。不过,这确实会将前两个 div 上的内容推到该元素的顶部。

但是,如果可能的话,我建议使用 Flexbox 来解决您可能遇到的一些定位问题。

https://css-tricks.com/snippets/css/a-guide-to-flexbox/

如果你要走 Flexbox 路线,这里是一个起点:

首先,您需要将前三个 div 包装在另一个 div 中.类似于 <div class="top-container"> - 查看添加到 top-container 的样式下面。

html,body { 
margin:0;
padding: 0;
display: flex;
flex-direction: column;
height: 100vh;
}
.top-container {
display: flex;
flex-direction: row;
align-items: flex-end;
height: calc(100vh - 200px);
}
#inputpanel {
width: calc(40vw - 10px);
}
#selectpanel {
width: calc(20vw - 10px);
}
#colorpanel {
width: calc(40vw - 10px);
}
#inputpanel,#selectpanel,#colorpanel {
display: inline-block;
box-sizing: border-box;
margin: 0;
padding: 0;
}
.b_footer {
padding: 10px;
height: 200px;
background-color: blue;
text-align: center;
color: white;
font-weight: bold;
box-sizing: border-box;
}
.colorbuttons {
background-color: #0000ff;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
width: 30%;
margin: 10px;
}

关于html - Div 不在同一高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45087772/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com