繁体   English   中英

定位背景图像

[英]Positioning a background image

所以我使用以下html标记一个简单的登录表单;

<form>
    <label>Username:</label>
        <input type="text" name="username" required="required" />
    <label>Password:</label>
        <input type="password" name="password" required="required" />
        <input type="submit" value="Login" name="submit" class="submit" />

我给它了以下造型;

form {
background:url(images/logo.png) no-repeat;
width: 250px;
padding: 20px;
padding-top:120px;
margin: 200px auto;
-webkit-border-radius: 1em; 
-moz-border-radius: 1em;
border-radius: 1em;
border: 1px solid #DDD;

/*** Shadow behind the box ***/
-moz-box-shadow:0px 2px 5px #e0e0e0;
-webkit-box-shadow:0px 2px 5px #e0e0e0;

}

除了我想要在窗体顶部居中的背景图像的位置之外,一切都有效。 目前位于左上方。 只是想知道除了为图像创建一个单独的div之外还有办法解决这个问题吗?

背景位置:顶部中心;

你的意思是将背景定位到表单背景的中心吗? 那背景位置呢?

您可以通过在背景线中添加“中心顶部”来定位背景,以便获得背景:url(images / logo.png)中心顶部无重复;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM