简体   繁体   English

HTML div:垂直对齐不会粘滞

[英]HTML divs: Vertical alignment will not stick

Having looked through days of possible solutions, I would like to ask now of a weird issue that I cannot seem to fix. 经过数天的可能解决方案,我现在想问一个我似乎无法解决的怪异问题。

The problem is that I cannot get the two divs below to correctly align so that they do NOT overlap when the page is resized. 问题是我无法使下面的两个div正确对齐,以便在调整页面大小时它们不会重叠。 Currently when the page is resized, the content div either expands to be far away from the header div or once it reaches a certain size, goes underneath the header never to be seen again. 当前,在调整页面大小时,内容div可能会扩展到与标头div相距甚远,或者一旦达到某个大小,它就会在标头下方进入,不再可见。 I am a relatively new to HTML5/CSS3 so I am certain that the error is something minimal that I have not thought to do, although I have tried the majority (if not all) of the solutions previously posed. 我对HTML5 / CSS3相对较新,因此可以肯定该错误是我从未想到的最小错误,尽管我尝试了以前提出的大多数(如果不是全部)解决方案。

Currently I have two divs that look like this: 目前,我有两个如下所示的div:

<div id="header" class="mm-fixed-top">
    <a href="#menu"><img src="images/mmenu.png" id="burg"></a>
    <img id="logo" src="images/cpit_landscape_white.png">
</div>

<div id="content">
    <h1>Lorem Ipsum</h1>
    <span>Sed ut perspiciatis unde omnis iste natus error sit...</span>
</div>

Currently with the following CSS link to these divs: 当前具有以下指向这些div的CSS链接:

    #header {
    height:10%;
    width: 100%;
    background: #0193CF url(../images/banner_decal.png) repeat-x 0 0;
    padding: 7px;
    color: #FFF;
    display: block;
}

#content {
    font-size:1em/150%;
    font-family: Arial, Helvetica, sans-serif;
    display:block;
    margin:8px;
    background:#f8f8f8;
    padding: 2%;
    margin-top: 14%;
}

The mm classes are in relation to the mmenu jQuery plugin. mm类与mmenu jQuery插件有关。

*Live edition of issue: http://sch242.comeze.com/mobile.php *发行版: http//sch242.comeze.com/mobile.php

Vertical percentages are a bit of a mine field and I'd advise against them in most cases. 垂直百分比有点像雷区,在大多数情况下,我建议不要这样做。 I'd advise doing something like this: 我建议做这样的事情:

#header {height: 5em;}
#content {margin-top: 8em;}

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

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