我要做的是创建一个输入字段,并将其放在页面的中心。我已经设法做到了这一点,但它看起来像是一个输入框在另一个输入框的顶部,它没有注意到我给它的样式规则。下面是它看起来的样子:

显然,黑色和灰色的框应该是输入框。
下面是HTML:
<style media="screen" type="text/css">
.styles{
height:30px;
width:286px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
-moz-background-clip: padding;
-webkit-background-clip: padding-box;
background-clip: padding-box;
border: 1px solid #5E5E5E;
padding:0 10px;
background-color: #000000;
color:#BFBFBF;
outline: none;
input-align: center;
}
.abs-centered {
margin: auto;
position: absolute;
bottom: 0;
left: 0;
top: 0;
right: 0;
}
</style>
<div class="styles abs-centered">
<body bgcolor="#25383C">
<input name="name" type="password" placeholder="Password" autocomplete="off"/>
</div>我还没有把html和body之类的东西放进去,因为我只是想解决这个问题。
发布于 2013-08-17 07:48:47
不要为输入框的外观使用单独的div。
使用以下命令:
input
{
//put the styling in here
}发布于 2013-08-17 07:49:17
您要将样式应用于<div>,而不是实际的<input>。可以将<div>看作是一个容器,其中包含您的主体和输入。(顺便说一句,<body>应该包含页面上显示的所有内容,而不是包含在<html>标记之外的任何内容中)。
将样式应用于<input>元素,而不是<div>,您将获得所需的效果。
发布于 2013-08-17 07:52:59
您可以使用CSS修复该问题,如下所示:
input{
/*My CSS Code*/
}但是不推荐这样做,因为你也有一个input type="submit",这会有一个问题,因为你会在按钮上有文本框设计。
下面是编辑input type="text"更流行、更具体的方法
input[type="text"]{
/*My Code*/
}如你所知,它可以用于type="password", type="submit"等。
https://stackoverflow.com/questions/18283602
复制相似问题