gpt4 book ai didi

html - 在背景中心对齐按钮

转载 作者:太空宇宙 更新时间:2023-11-03 19:24:57 24 4
gpt4 key购买 nike

我是 CSS 等方面的新手。

我试图将 2 个按钮彼此相邻对齐,位于背景图像的中心,因此即使在调整窗口大小时它也保持在原位。

插图图片:enter image description here

代码:

body {
background-image: url('/image/bgcopy.png'), url(/image/bg2.jpg);
background-repeat: no-repeat, no-repeat;
background-attachment: fixed, fixed;
background-size: contain, cover;
background-position: center;
}

.button {
width: 200px;
height: 70px;
margin: 20px;
text-align: center;
}

.container {
text-align: center;
margin: 0 auto;
}

.button1 {
background-color: transparent;
color: white;
border: 2px solid red;
display: inline-block;
}

.button2 {
background-color: transparent;
color: white;
border: 2px solid red;
display: inline-block;
}
<div class="container">
<button class="button button1"><a href="/nl">Lang1</a></button>
<button class="button button2"><a href="/fr">Lang2</a></button>
</div>

最佳答案

所以,也许你可以试试:

.container{    
position: absolute;
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
}

或者你见过关于flexbox的任何事情吗? ?由于您希望它具有响应性,因此我认为这可能是最好的选择。

.container {
display: flex;
align-items: center;
justify-content: space-around;
}

关于html - 在背景中心对齐按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58695921/

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