gpt4 book ai didi

css - Margin Auto 需要居中

转载 作者:行者123 更新时间:2023-11-28 13:05:44 25 4
gpt4 key购买 nike

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

    <!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>

它随页面调整大小,但我无法将整个内容置于页面中央。我只想将整个内容放在页面中间

最佳答案

去掉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 Live Demo

关于css - Margin Auto 需要居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15856221/

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