0

这是我的代码我试图让它在页面中间居中

    <!DOCTYPE html>
<html lang="en">
<head>
<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
<title>cp</title>
</head>
<body>
<div class="well">
  <font face="arial" size="5" color="#000000"><center><b>Control Panel</font></center>
</div>
</style>

<style type="text/css">
.span12{
background: lightblue;
color: while;
padding: 9px 0;
border-radius:5px;
text-align: center;
border: 1px #00BFFF solid;
margin: 0px auto;
width: 50%;
margin-top: 25%;
}
</style>
<div class="span12">
Welcome
</div>
<script src="js/bootstrap.js"></script>

它随页面重新调整大小,但我无法将整个内容放在页面的中心。我只想把整个东西放在页面中间

4

1 回答 1

0

删除center标签并设置margin-top:25%,它将解决您的问题。

CSS

.span12{
background: lightblue;
color: while;
padding: 9px 0;
border-radius:5px;
text-align: center;
border: 1px #00BFFF solid;
margin: 0px auto;
width: 50%;
margin-top:25%; /* new */
}

HTML

<div class="span12">
Welcome
</div>

jsFiddle 现场演示

于 2013-04-06T21:39:58.910 回答