我需要在地图上放置两个浮动面板,但float: right不工作。请帮帮忙。
我尝试了所有的方法,但似乎是position: absolute禁用了float: right或其他什么。
有没有办法在不改变第一个面板的对齐方式的情况下将第二个面板(#浮动-panel2)向右对齐?
我需要这样的东西:

这是我的html和css:
#wrapper { position: relative; }
#floating-panel1 {
position: absolute;
width: 265px;
top: 55px;
left: 5px;
z-index: 5000;
background-color: rgb(66, 72, 79);
padding: 5px;
border: 1px solid rgb(66, 72, 79);
border-radius: 1px;
}
#floating-panel2 {
position: absolute;
width: 265px;
top: 55px;
left: 0px;
z-index: 5000;
background-color: rgb(66, 72, 79);
padding: 5px;
border: 1px solid rgb(66, 72, 79);
border-radius: 1px;
float:right;
}<div id="wrapper" style="height: 100vh">
<div id="floating-panel1">
<h1>PANEL 1</h1>
</div>
<div id="floating-panel2">
<h1>PANEL 2</h1>
</div>
</div>
请帮帮忙
发布于 2018-02-15 03:27:09
这就是你要找的吗?如果是,您所要做的就是在第二个面板上将left: 5px更改为right: 5px。
#wrapper { position: relative; }
#floating-panel1 {
position: absolute;
width: 265px;
top: 55px;
left: 5px;
z-index: 5000;
background-color: rgb(66, 72, 79);
padding: 5px;
border: 1px solid rgb(66, 72, 79);
border-radius: 1px;
}
#floating-panel2 {
position: absolute;
width: 265px;
top: 55px;
right: 5px;
z-index: 5000;
background-color: rgb(66, 72, 79);
padding: 5px;
border: 1px solid rgb(66, 72, 79);
border-radius: 1px;
}<div id="wrapper" style="height: 100vh">
<div id="floating-panel1">
<h1>PANEL 1</h1>
</div>
<div id="floating-panel2">
<h1>PANEL 2</h1>
</div>
</div>
发布于 2018-02-15 14:06:25
使用float:left和float:right显示div,并将位置添加到div1 position:absolute和div2 position:relative。
#wrapper { position: relative; }
#floating-panel1 {
width: 265px;
top: 55px;
float:left;
position:absolute;
z-index: 5000;
background-color: rgb(66, 72, 79);
padding: 5px;
border: 1px solid rgb(66, 72, 79);
border-radius: 1px;
}
#floating-panel2 {
width: 265px;
top: 55px;
float:right;
position:relative;
z-index: 5000;
background-color: rgb(66, 72, 79);
padding: 5px;
border: 1px solid rgb(66, 72, 79);
border-radius: 1px;
float:right;
}<div id="wrapper" style="height: 100vh">
<div id="floating-panel1">
<h1>PANEL 1</h1>
</div>
<div id="floating-panel2">
<h1>PANEL 2</h1>
</div>
</div>
https://stackoverflow.com/questions/48794705
复制相似问题