gpt4 book ai didi

html - 使用 CSS 和 HTML 水平对齐图像和表单

转载 作者:太空宇宙 更新时间:2023-11-04 16:10:45 27 4
gpt4 key购买 nike

alignment fail

我想对齐这些,以便登录和注册与大括号的中心垂直对齐,并且所有内容(输入框/标签除外)在屏幕上都是水平的。

这是我的 HTML:

 <body>
<img src="{{ STATIC_URL}}logo.png" class='center'></br>
<div style:"display:inline;">
<a href='#' title='click to login' onClick='login()'>login</a>
<img src="{{ STATIC_URL}}leftParens.png" style:"display:inline">
<form method='post' action='login' id='loginForm'>
{% csrf_token %}
<label for="username">username</label>
<input name="username" type="text" id="username" face="helvetica"/>
</br>
<label for="password">password</label>
<input name="password" type="password" id="password" face="AmericanTypewriter"/>
</form>
<img src="{{ STATIC_URL}}rightParens.png" style:"display:inline">
<a title='signup for omnicloud' href='signup' class='login_signup_button'>signup</a>
</div>
</body>

以及对应的CSS:

@font-face{
font-family:AmericanTypewriter;
src:url('AmericanTypewriter.TTF');
}

body{
background-color:rgb(71,103,255);
text-align:center;
}

img.center{
margin-left: auto;
margin-right: auto;
width:500px;
}

/* Used for braces */
form,fieldset,h1,h2,a,label{
margin:0;
padding:0;
font:30px/32px normal 'AmericanTypewriter', courier, sans-serif;
color:#fff;
display:inline;
}

a{
vertical-align: 50%;
}

input{
margin:0;
padding:0;
font:20px/22px normal 'AmericanTypewriter', courier, sans-serif;
color:rgb(48,94,255);
}

/* Used for login, signup, username, password */
#loginForm{
display:block;
margin:50px auto;
height:100px;
}

目标: enter image description here

最佳答案

首先,我会修改您的 HTML 以将其排列成框。例如,我会把你的 <a href>对于登录链接和相应的 <img>进入一个单独的分区;并对注册做同样的事情 <a href><img> .将这些标签放入它们自己的框中将允许您绝对定位登录链接,并将登录链接移动到您想要的位置,内部包含 div 的范围内。不确定您希望页面的其余部分如何定位,您能澄清一下吗?

关于html - 使用 CSS 和 HTML 水平对齐图像和表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8426107/

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