gpt4 book ai didi

html - 如何将div放置在彼此之上并水平对齐

转载 作者:太空宇宙 更新时间:2023-11-04 09:02:52 24 4
gpt4 key购买 nike

我现在有这个;

enter image description here

但是我想要的是这个;

enter image description here

我如何对所有内容进行 CSS,我已经尝试过但未能完成。首先,我需要拆分我的 svg,使顶部位于登录表单后面,底部位于登录表单前面。但是,我如何才能让他们在拳头上相互超越呢?

我的 html;

<body>
<div class="container">
<div class="login-page">
<form action="xxxx" method="post">
<h1>Wsdfgdfgb</h1>
<input class="input" type="text" name="_username" placeholder="xxxx"
value="xxxx" required />
<input class="input" type="password" name="_password"
placeholder="xxxx" required />
<label class="text" for="remember_me">
<input type="checkbox" id="remember_me" name="_remember_me" value="on" />
Remember me
</label>
<button>Log In</button>
</form>
</div>
<div class="svg-container">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="500px" height="250px" viewBox="0 0 1920 960" enable-background="new 0 0 1920 960" xml:space="preserve">
<g>
<path fill-rule="evenodd" clip-rule="evenodd" fill="#000" d="M64.91,510.275c1.152,15.744,5.364,30.809,10.41,45.648......"/>
</g>
</svg>
</div>
</div>
</body>

还有我的 CSS;

body {
background: #1AB394; /* fallback for old browsers */
background: -webkit-linear-gradient(right, #1AB394, #008374);
background: -moz-linear-gradient(right, #1AB394, #008374);
background: -o-linear-gradient(right, #1AB394, #008374);
background: linear-gradient(to left, #1AB394, #008374);
font-family: "Roboto", sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

.container {
position: absolute;
left: 50%;
}

.login-page {
position: relative;
left: -50%;
width: 360px;
padding: 8% 0 0;
margin: auto;
}

.svg-container {
position: relative;
left: -50%;
z-index: 1000;
}

form {
position: relative;
z-index: 1;
background: #FFFFFF;
max-width: 360px;
margin: 0 auto 100px;
padding: 45px;
box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24);
}

form h1 {
text-align: center;
margin: 0 0 15px;
padding: 0;
font-size: 36px;
font-weight: 300;
color: #1a1a1a;
}

form input[type="text"], form input[type="password"] {
font-family: "Roboto", sans-serif;
outline: 0;
background: #f2f2f2;
width: 100%;
border: 0;
margin: 0 0 15px;
padding: 15px;
box-sizing: border-box;
font-size: 14px;
}

form input[type="checkbox"] {
font-family: "Roboto", sans-serif;
outline: 0;
background: #f2f2f2;
border: 0;
margin: 0 0 15px;
padding: 15px;
box-sizing: border-box;
font-size: 14px;
}

form .text {
color: #b3b3b3;
font-size: 14px;
}

form .err {
color: #EF3B3A;
font-size: 14px;
text-align: center;
margin: 0 0 15px;
}

form button {
font-family: "Roboto", sans-serif;
text-transform: uppercase;
outline: 0;
background: #1AB394;
width: 100%;
border: 0;
padding: 15px;
color: #FFFFFF;
font-size: 14px;
-webkit-transition: all 0.3 ease;
transition: all 0.3 ease;
cursor: pointer;
}

form button:hover,form button:active,form button:focus {
background: #18A689;
}

最佳答案

.login-page.svg-container都有position: absolute,给它们一个z-index ,使.svg-container的z-index高于另一个,并相应调整位置。

关于html - 如何将div放置在彼此之上并水平对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42653148/

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