gpt4 book ai didi

CSS定位2

转载 作者:行者123 更新时间:2023-11-28 14:29:54 27 4
gpt4 key购买 nike

我希望我的 block 居中。每次我打开一个 div 它都会向左倾斜。代码是:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />


<title>SGKM</title>

<style type="text/css">



body{
margin:0 auto;
}

body

{
font:13px/22px Arial;
color:#444;
}

.container{

}
.container2{
clear:both;
}

a{

color:#000;

}



.stage

{

height:150px;

width:200px;

border:1px solid #f0f0f0;

background:#fafafa;

margin:60px auto;

}



.docIcon {
background: #eee;

background: -webkit-linear-gradient(top, #ddd 0, #eee 15%, #fff 40%, #fff 70%, #eee 100%);
background: -moz-linear-gradient(top, #ddd 0, #eee 15%, #fff 40%, #fff 70%, #eee 100%);
background: -o-linear-gradient(top, #ddd 0, #eee 15%, #fff 40%, #fff 70%, #eee 100%);
background: -ms-linear-gradient(top, #ddd 0, #eee 15%, #fff 40%, #fff 70%, #eee 100%);
background: linear-gradient(top, #ddd 0, #eee 15%, #fff 40%, #fff 70%, #eee 100%);

border: 1px solid #ccc;
display: block;
width: 26px;
height: 50px;

float:left;
text-align:center;
}
.docIcon2 {
background: #eee;

background: -webkit-linear-gradient(top, #ddd 0, #eee 15%, #fff 40%, #fff 70%, #eee 100%);
background: -moz-linear-gradient(top, #ddd 0, #eee 15%, #fff 40%, #fff 70%, #eee 100%);
background: -o-linear-gradient(top, #ddd 0, #eee 15%, #fff 40%, #fff 70%, #eee 100%);
background: -ms-linear-gradient(top, #ddd 0, #eee 15%, #fff 40%, #fff 70%, #eee 100%);
background: linear-gradient(top, #ddd 0, #eee 15%, #fff 40%, #fff 70%, #eee 100%);

border: 1px solid #ccc;
display: block;
width: 29px;
height: 50px;

float:right;
text-align:center;
}

.doc3{width: 23px;
height: 50px;
float:left;
border: 1px solid #ccc;
text-align:center;}


</style>

</head>



<body>


<div class="stage">
<center><h2>Sahne</h2></center>
</div>
<div class="container">
<a href="#" class="doc3"></a>


<a class="doc3"></a>
<a href="#" class="doc3"></a>


<a href="#" class="docIcon">A<br>24</a>
<a href="#" class="docIcon">A<br>23</a>
<a href="#" class="docIcon">A<br>22</a>
<a href="#" class="docIcon">A<br>21</a>
<a href="#" class="docIcon">A<br>20</a>
<a href="#" class="docIcon">A<br>19</a>
<a href="#" class="docIcon">A<br>18</a>

<a href="#" class="doc3"></a>


<a href="#" class="doc3"></a>

<a href="#" class="docIcon">A<br>17</a>
<a href="#" class="docIcon">A<br>16</a>
<a href="#" class="docIcon">A<br>15</a>
<a href="#" class="docIcon">A<br>14</a>
<a href="#" class="docIcon">A<br>13</a>
<a href="#" class="docIcon">A<br>12</a>
<a href="#" class="docIcon">A<br>11</a>
<a href="#" class="docIcon">A<br>10</a>
<a href="#" class="docIcon">A<br>9</a>
<a href="#" class="docIcon">A<br>8</a>

<a href="#" class="doc3"></a>
<a href="#" class="doc3"></a>

<a href="#" class="docIcon">A<br>7</a>
<a href="#" class="docIcon">A<br>6</a>
<a href="#" class="docIcon">A<br>5</a>
<a href="#" class="docIcon">A<br>4</a>
<a href="#" class="docIcon">A<br>3</a>
<a href="#" class="docIcon">A<br>2</a>
<a href="#" class="docIcon">A<br>1</a>

</div>
<div class="container2">
<a href="#" class="docIcon">B<br>27</a>
<a href="#" class="docIcon">B<br>26</a>
<a href="#" class="docIcon">B<br>25</a>
<a href="#" class="docIcon">B<br>24</a>
<a href="#" class="docIcon">B<br>23</a>
<a href="#" class="docIcon">B<br>22</a>
<a href="#" class="docIcon">B<br>21</a>
<a href="#" class="docIcon">B<br>20</a>
<a href="#" class="doc3"></a>


<a href="#" class="doc3"></a>
<a href="#" class="docIcon">B<br>19</a>
<a href="#" class="docIcon">B<br>18</a>
<a href="#" class="docIcon">B<br>17</a>
<a href="#" class="docIcon">B<br>16</a>
<a href="#" class="docIcon">B<br>15</a>
<a href="#" class="docIcon">B<br>14</a>
<a href="#" class="docIcon">B<br>13</a>
<a href="#" class="docIcon">B<br>12</a>
<a href="#" class="docIcon">B<br>11</a>
<a href="#" class="docIcon">B<br>10</a>
<a href="#" class="docIcon">B<br>9</a>
<a href="#" class="doc3"></a>
<a href="#" class="doc3"></a>
<a href="#" class="docIcon">B<br>8</a>
<a href="#" class="docIcon">B<br>7</a>
<a href="#" class="docIcon">B<br>6</a>
<a href="#" class="docIcon">B<br>5</a>
<a href="#" class="docIcon">B<br>4</a>
<a href="#" class="docIcon">B<br>3</a>
<a href="#" class="docIcon">B<br>2</a>
<a href="#" class="docIcon">B<br>1</a>

</div>
<div class="container2">
<a href="#" class="docIcon">G<br>36</a>
<a href="#" class="docIcon">G<br>35</a>
<a href="#" class="docIcon">G<br>34</a>
<a href="#" class="docIcon">G<br>33</a>
<a href="#" class="docIcon">G<br>32</a>
<a href="#" class="docIcon">G<br>31</a>
<a href="#" class="docIcon">G<br>30</a>
<a href="#" class="docIcon">G<br>29</a>
<a href="#" class="docIcon">G<br>28</a>
<a href="#" class="docIcon">G<br>27</a>
<a href="#" class="docIcon">G<br>26</a>
<a href="#" class="docIcon">G<br>23</a>
<a href="#" class="docIcon">G<br>22</a>
<a href="#" class="docIcon">G<br>21</a>
<a href="#" class="docIcon">G<br>20</a>
<a href="#" class="docIcon">G<br>19</a>
<a href="#" class="docIcon">G<br>18</a>
<a href="#" class="doc3"></a>
<a href="#" class="doc3"></a>
<a href="#" class="docIcon">G<br>25</a>

<a href="#" class="docIcon">G<br>24</a>
<a href="#" class="docIcon">G<br>23</a>
<a href="#" class="docIcon">G<br>22</a>
<a href="#" class="docIcon">G<br>21</a>
<a href="#" class="docIcon">G<br>20</a>
<a href="#" class="docIcon">G<br>19</a>
<a href="#" class="docIcon">G<br>18</a>



<a href="#" class="docIcon">G<br>17</a>
<a href="#" class="docIcon">G<br>16</a>
<a href="#" class="docIcon">G<br>15</a>
<a href="#" class="docIcon">G<br>14</a>
<a href="#" class="docIcon">G<br>13</a>
<a href="#" class="docIcon">G<br>12</a>
<a href="#" class="docIcon">G<br>11</a>
<a href="#" class="doc3"></a>
<a href="#" class="doc3"></a>
<a href="#" class="docIcon">G<br>10</a>
<a href="#" class="docIcon">G<br>9</a>
<a href="#" class="docIcon">G<br>8</a>



<a href="#" class="docIcon">G<br>7</a>
<a href="#" class="docIcon">G<br>6</a>
<a href="#" class="docIcon">G<br>5</a>
<a href="#" class="docIcon">G<br>4</a>
<a href="#" class="docIcon">G<br>3</a>
<a href="#" class="docIcon">G<br>2</a>
<a href="#" class="docIcon">G<br>1</a>



</body>

</html>

最佳答案

如果你在谈论你的字母/按钮类型 block ,原因很简单:

全部向左浮动。

您称为 container 的 div 中没有任何 solid 元素,因此显示为空。

此代码段能否部分解决您的问题?

.container {margin:0px auto; width:968px;}
.container2 {margin:0px auto;width:700px;}
a {display:inline-block !important;float:none!important;}

这是它的作用:

  1. 为您的容器 元素指定最大宽度并根据此宽度居中。 (问题:宽度不是动态的,所以它不会对其中的元素数量使用react......
  2. 重置 a 元素的 float 并将它们定义为 inline-block 以便它们彼此相邻,但仍然是 block 元素(具有维度)。<

注意:我建议您不要使用它,它是错误代码。请根据我提供给您的信息重新考虑您的风格。

关于CSS定位2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7504548/

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