【问题标题】:drop down menu push down white space?下拉菜单下推空白?
【发布时间】:2013-10-26 06:59:34
【问题描述】:

我想在放大后删除下拉菜单。放大时,页面有额外的空白。放大后如何删除下拉菜单? Here is my JsFiddle.

HTML

<body>
<div class="Top_Section">
<div class="Top_Warpper">
<div class="Pm_Logo"><a href="#"><h1>PM</h1></a></div>
<div class="Menu_Nav">
    <ul>
        <li><a href="#">About</a></li>
        <li><a href="#">Work</a></li>
        <li><a href="#">Publishing Solutions</a></li>
        <li><a href="#">Contact Us</a></li>
    </ul>
</div><!--end Menu_Nav-->
</div><!--end top warpper-->
</div><!--end top section-->

    <div class="redbg"></div>
</body>

<footer>
<div class="footer_warpper"></div><!--end of footer_warpper-->
</footer>

CSS

/*----Main menu css
----------------------------------------*/

.redbg{
    width:100%;
    height:700px;
    background-color:red;
}

.Top_Section{
position:fixed;
background:#000;
width:100%;
z-index:3000;
text-align:center;
}

.Top_Warpper{
max-width:970px;/*focus on the center view , so when zoom in it wont zoom to left*/
height:70px;
text-align:center;
margin:0px;
padding:0px;
background-color:#000;
margin-right:auto;
margin-left:auto;
}


.Pm_Logo{
position:relative;
top:0px;
float:left;
padding:0px;
margin:0px;
}

.Pm_Logo h1:hover {
color:#DAFF00;
}

.Pm_Logo h1{
    position:relative;
    margin:5px 5px;
    font-family:"Kunstware1.0 ALP", "helvetica neue", helvetica, arial, sans-serif;
    border: none; /*IE border fixed*/
    font-size:49.5px;
    display:inline-block;
    color:white;
}

.Menu_Nav{
padding:10px;
margin-bottom:10px;
}

.Menu_Nav ul{
margin:0px;
padding:0px;
}

.Menu_Nav ul li{
margin-top:17px;/*make the drop down meun stick to auto height , so it wont  over lap*/
display:inline;
list-style:none;
padding:10px 5px 10px 5px;
float:right; 
}

.Menu_Nav a{
font-style: italic; font-size: 1.1em;
list-style:none;
text-decoration: none;
padding:5px;
color:white;
font-weight:bold;
-webkit-transition: all .1s ease-out;
-moz-transition: all .1s ease-out;
-ms-transition: all .1s ease-out;
-o-transition: all .1s ease-out;
transition: all .1s ease-out;
background-color:red;
}

.Menu_Nav a:hover{
color:#DAFF00;
}


@media screen and (max-width: 480px) {

.Top_Section{
position:relative;
display:inline-block; 
margin:0px;
padding:0px;
}

.Menu_Nav ul{
font-size:10px;
display:inline-block;
}

}

Here is my JsFiddle。请放大并查看问题,谢谢。

【问题讨论】:

  • 放大是什么意思?我不明白你的问题
  • @GEspinha 我认为这意味着页面缩放(CTRL + Scroll Up)。

标签: html css


【解决方案1】:

这是你要找的吗?

http://jsfiddle.net/gespinha/Tbc4v/3/

第一期

您正在分配 div .Top_Wrapper 一个固定的 height 所以它不会 拉伸,保持黑色标题背景静态时 调整屏幕大小。

第二期

您还将菜单li 元素分配给float: right; 属性,使这些元素脱离正常的文档流 因此需要一个具有clear 属性的元素来重新分配这些 列出文档流的项目。

这使得标题.Top_Wrapper div 跟随其子元素的位置并根据当前元素显示调整其大小。

.clear{
   clear:both;
}

(在这种情况下,clear 元素的值应该是right,但我使用了both,以防您需要在项目的其余部分重用它)

【讨论】:

  • 是的,它工作,是我想要的,我之前尝试过最小高度,但我想我从来没有想过要在上面添加一个明确的,感谢你的帮助,很好的答案,我很好理解。
猜你喜欢
  • 1970-01-01
  • 2019-05-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-10-04
  • 2017-11-17
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多