简体   繁体   English

添加空格后出现意外的页边距上限[no-wrap]

[英]Unexpected margin-top after adding white-space [no-wrap]

Please help me stuck on this for four hours. 请帮我坚持四个小时。 I get this unexpected space the circle black mark 我得到这个意想不到的空间,圆圈黑色标记 意外的空间 above my pagination when I use white-space: nowrap; 当我使用white-space: nowrap;时,在分页之上white-space: nowrap; on div, please how do i go about solving this, I have tried adding margin-top:-50px!important; 在div上,请问如何解决这个问题,我尝试添加margin-top:-50px!important; but it just stays there and does not move according to the margin rule. 但它只是停留在那儿,不会按照边距规则移动。

<div class="container">
    <div style="height:50px;background-color:#eee;overflow-x:auto;white-space: nowrap;width:100%;margin-bottom:40px;border:1px solid #000;"> //I guess this is what makes the unexpected space, PLEASE HELP.
        <div align="center" style="padding-top:10px;">
            <div id="pagination_controls" draggable="false" ondragstart="return false">
                <?php echo $paginationCtrls; ?>
            </div>
        </div>
    </div>
</div>


<style>
div#pagination_controls {
  position: absolute;
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -o-user-select: none;
  font-size: 21px;
  width: 90%;
  max-width: 90%;
  overflow-x: auto!important;
  margin-left: ;
}

div#pagination_controls>a {
  color: #06F;
  margin-top: 50px;
}

div#pagination_controls>a:visited {
  color: #06F;
}

#pagination_controls a.main-nav-item:hover {
  background-color: #fff!important;
  padding-top: 7px;
  padding-bottom: 7px;
  border: 1px solid #000;
  padding-left: 5px;
  padding-right: 5px;
  color: #000;
}
</style>

Just make the div position:absolute; 只需将div position:absolute;设为position:absolute; then you can place it anywhere. 然后您可以将其放置在任何地方。 Specify the desired top: you need. 指定所需的top:您需要。 Can be done like this - 可以这样做-

<div class="container">
    <div style="position:absolute;top:10px;height:50px;background-color:#eee;overflow-x:auto;white-space: nowrap;width:100%;margin-bottom:40px;border:1px solid #000;"> //I guess this is what makes the unexpected space, PLEASE HELP.
        <div align="center" style="padding-top:10px;">
            <div id="pagination_controls" draggable="false" ondragstart="return false">
                <?php echo $paginationCtrls; ?>
            </div>
        </div>
    </div>
</div>

adding to what trex1999 said you can add z-index to it also. 除了trex1999所说的之外,您还可以在其中添加z-index。

<div class="container">
    <div style="z-index:800;position:absolute;top:10px;height:50px;background-color:#eee;overflow-x:auto;white-space: nowrap;width:100%;margin-bottom:40px;border:1px solid #000;"> //I guess this is what makes the unexpected space, PLEASE HELP.
        <div align="center" style="padding-top:10px;">
            <div id="pagination_controls" draggable="false" ondragstart="return false">
                <?php echo $paginationCtrls; ?>
            </div>
        </div>
    </div>
</div>

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

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