固定宽度居中

一般的主题在页面足够大时(比主题要大),主题是会自动居中的。其实很简单,以上一篇的登录框为例在这里插入图片描述
QQ空间和这个登录框是会自动居中的。代码就是加一个div,让他margin左右auto就可以

<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title></title>
		<style type="text/css">
			body {
				background-color: gray;
			}
			*{
				margin: 0px;
				padding: 0px;
				
			}
			body{
				height: 100%;
			}
			.container{
				width: 880px;
				margin: 0px auto;
				/*background-color: black;*/
				box-sizing: border-box;
				position: relative;
				top: 95px;
			}
			.container .logo{
				
				padding: 0px;
				margin: 0px;
				box-sizing: border-box;
			}
			
			.wrap {
				width: 414px;
				height: 312px;
				border: solid rgb(238, 238, 238) 2px;
				background-color: white;
				position: absolute;
				top: 0px;
				right: 0px;
				/*margin: 0px auto;*/
			}
			
			.wrap .title {
				margin-top: 6px;
				margin-bottom: 16px;
				font-size: 20px;
				color: rgb(51, 51, 51);
				text-align: center;
				/*居中*/
			}
			
			.wrap .infor {
				text-align: center;
				color: #666;
				font-size: 16px;
				margin-bottom: 36px;
			}
			
			.wrap .infor a {
				text-decoration: none;
				color: #3481cf;
			}
			
			.wrap #form {
				text-align: center;
				height: 150px;
				width: 272px;
				margin: 0px auto;
			}
			
			.wrap #form .input {
				height: 38px;
				width: 268px;
				box-sizing: border-box;
				padding: 10px;
				padding-right: 0px;
				margin-bottom: 17px;
				border-radius: 3px;
				border: solid rgb(214, 214, 21) 1px;
			}
			
			.wrap #form #btn {
				border-radius: 3px;
				height: 37px;
				width: 258px;
				padding: 1px 7px 2px 7px;
				box-sizing: content-box;
				border: none;
				background-color: rgb(136, 210, 48);
				color: white;
				font-size: 17px;
			}
		</style>
	</head>

	<body>
		<div class="container">
         <div class="logo" >
         	<img src="https://qzonestyle.gtimg.cn/qzone_v6/proj_qzonelogin/img/qzone-login-logo-dark.32@2x.png" width="251px" height="98px"/>
         </div>
			<div class="wrap">
				<!--登录框的最外部的框框-->
				<div class="title">
					<!--账号密码字体存放的div-->
					账号密码登录
				</div>
				<div class="infor">
					<!--第二行字存放的div-->
					推荐使用
					<a href="">快速安全登录</a>,防止盗号。
				</div>
				<form action="" method="post" id="form">
					<!--账号密码登录的一个from表单-->
					<input type="text" class="input" placeholder="支持QQ号/邮箱/手机号登录" />
					<input type="text" class="input" placeholder="密码" />
					<button type="button" id="btn">登 录</button>
					<!--简单来讲就是一个大的方块(wrap)包含了title,infor,from三大块的信息,from中又包含了账号,密码,登录三个块块-->

				</form>
			</div>
		</div>
	</body>

</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值