将叠加按钮与另一个按钮对齐 div

Align overlay button with button on another div

所以检查一下:

//Code for button a donde quieres ir 
//Start var
var nearby_search;
function nearby_choose(choice){
  nearby_search = choice;
}
//Overlay code
function nearby_search_on() {
  document.getElementById("nearby_search").style.display = "block";
}

function nearby_search_off() {
  document.getElementById("nearby_search").style.display = "none";
}
@font-face {
    font-family: biolinum;
    src: 'fonts/LinBiolinum_R.ttf';
}
@font-face {
    font-family: biolinum;
    src: 'fonts/LinBiolinum_RB.ttf';
    font-weight: bold;
}
@font-face {
    font-family: biolinum;
    src: 'fonts/LinBiolinum_RI.ttf';
    font-style: italic;
}
body {
    background-color: #FCF7F8;
    font-size: 62.5%;
    height: 100%;
    margin: 0px;
}
p {
    margin-block-start: 0rem;
    margin-block-end: 0rem;
}
h1 {
    margin-block-start: 0rem;
    margin-block-end: 0rem;
}
.domainhome {
    font-family: biolinum;
    font-size: 2rem;
    text-align: center;
    color: #1D263B;
    background-color: #FCF7F8;
    border: none;

    cursor: pointer;
    outline:none;

    margin-top: 2rem;
    margin-left: 5rem;
}
a:link {
    color: #1D263B;
    background-color: transparent;
    text-decoration: none;
}
a:visited {
    color: #1D263B;
    background-color: transparent;
    text-decoration: none;
}
.flex-container {
    display: flex;
    flex-shrink: 0;
    /* background-color: DodgerBlue; */
    margin-top: 4rem;
}
.left-bar {
    flex-direction: column;
    margin-left: 5rem;
}

.right-bar {
    flex-direction: column;
    margin-left: 5rem;
    margin-right: 5rem;

    height: 100%;
    width: 100%;
    
}

button {
    transition: 0.4s;
}
button:hover {
    transform: rotate(-1deg) translate(0px, -8px);
}
.adondequieresir {
    font-family: biolinum;
    font-size: 1.66rem;
    text-align: center;
    color: #FCF7F8;
    background-color: #1D263B;
    border: none;
    width: 275px;
    height: 75px;

    cursor: pointer;
    outline:none;

    margin-bottom: 3rem;
}
.agregarubicacion {
    font-family: biolinum;
    font-size: 1.33rem;
    text-align: center;
    color: #FCF7F8;
    background-color: #1D263B;
    border: none;
    width: 275px;
    height: 50px;
    border-radius: 50px;

    cursor: pointer;
    outline:none;

    margin-bottom: 3rem;
}
.personasunidas {
    font-family: biolinum;
    font-size: 1.33rem;
    text-align: center;
    color: #FCF7F8;
    background-color: #1D263B;
    border: none;
    width: 275px;
    height: 50px;
    border-radius: 50px;

    cursor: pointer;
    outline:none;

    margin-bottom: 3rem;
}
.icons {
    float: left; 
    margin-left: 7px;
    margin-right: 10px;
}

#map {
    height: 400px;
}

#nearby_search {
    position: fixed; 
    display: none;
    width: 100%; 
    height: 100%; 
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.5);
    z-index: 2; 
}
<!DOCTYPE html>
<html>
<head>
</head>
<body>
    <div class="flex-container">
        <div class="left-bar">

            <div>
                <button onClick="nearby_search_on()" class="adondequieresir"><p>¿a dónde quieres ir?</p></button>

                <div id="nearby_search">
                    <button onClick="nearby_search_off()" class="adondequieresir" style="background-color: #A288E3;"><p>¿a dónde quieres ir?</p></button>
                </div>
            </div>
    </div>
</body>
</html>

我正在尝试创建类似下拉菜单的东西,但更时尚。所以我决定不使用标签,而是使用 javascript 变量和按钮来实现我的目标。但关键是,当单击按钮时,我希望它变亮,使后面的一切变暗,并(最终)添加其他带有可供选择的选项的按钮。上面的片段是我的(错误的)方法。例如,我实际上使用 两个 按钮来尝试模拟几乎相同的“¿a donde quieres ir”按钮的颜色变化。我怎样才能响应地对齐这两个按钮?什么是最干净的方式来完成我想要的整体?如果有任何帮助,我将不胜感激:)

我觉得你可以用一个按钮,把它和背景分开,然后用'z-index'把按钮放上去

function nearby_search_toggle() {
    var tmpDisplay = document.getElementById("tmpBg");
    var tmpBtn = document.getElementById("tmpBtn");
    if (tmpDisplay.style.display == 'block') {
        tmpDisplay.style.display = "none";
        tmpBtn.classList.remove('active');
    } else {
        tmpDisplay.style.display = "block";
        tmpBtn.classList.add('active');
    }
}
body {
    background-color: #FCF7F8;
    font-size: 62.5%;
    height: 100%;
    margin: 0px;
}

p {
    margin-block-start: 0rem;
    margin-block-end: 0rem;
}

h1 {
    margin-block-start: 0rem;
    margin-block-end: 0rem;
}

.domainhome {
    font-family: biolinum;
    font-size: 2rem;
    text-align: center;
    color: #1D263B;
    background-color: #FCF7F8;
    border: none;
    cursor: pointer;
    outline: none;
    margin-top: 2rem;
    margin-left: 5rem;
}

a:link {
    color: #1D263B;
    background-color: transparent;
    text-decoration: none;
}

a:visited {
    color: #1D263B;
    background-color: transparent;
    text-decoration: none;
}

.flex-container {
    display: flex;
    flex-shrink: 0;
    /* background-color: DodgerBlue; */
    margin-top: 4rem;
}

.left-bar {
    flex-direction: column;
    margin-left: 5rem;
}

.right-bar {
    flex-direction: column;
    margin-left: 5rem;
    margin-right: 5rem;
    height: 100%;
    width: 100%;
}

button {
    transition: 0.4s;
}

button:hover {
    transform: rotate(-1deg) translate(0px, -8px);
}

.adondequieresir {
    position: relative;
    font-family: biolinum;
    font-size: 1.66rem;
    text-align: center;
    color: #FCF7F8;
    background-color: #1D263B;
    border: none;
    width: 275px;
    height: 75px;
    cursor: pointer;
    outline: none;
    margin-bottom: 3rem;
    z-index: 2;
}

.adondequieresir.active {
    background-color: white;
    color: red;
}

#tmpBg {
    position: fixed;
    display: none;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1;
}

.agregarubicacion {
    font-family: biolinum;
    font-size: 1.33rem;
    text-align: center;
    color: #FCF7F8;
    background-color: #1D263B;
    border: none;
    width: 275px;
    height: 50px;
    border-radius: 50px;
    cursor: pointer;
    outline: none;
    margin-bottom: 3rem;
}

.personasunidas {
    font-family: biolinum;
    font-size: 1.33rem;
    text-align: center;
    color: #FCF7F8;
    background-color: #1D263B;
    border: none;
    width: 275px;
    height: 50px;
    border-radius: 50px;
    cursor: pointer;
    outline: none;
    margin-bottom: 3rem;
}

.icons {
    float: left;
    margin-left: 7px;
    margin-right: 10px;
}

#map {
    height: 400px;
}
<div class="flex-container">
    <div class="left-bar">
        <div>
            <div id="tmpBg"></div>
            <button onClick="nearby_search_toggle();" class="adondequieresir" id="tmpBtn">
                <p>¿a dónde quieres ir?</p>
            </button>
        </div>
    </div>
</div>