0

我有一个由页眉、正文和页脚的一系列 div 组成的对话框,这些 div 进一步细分为左、中和右部分。想象一个井字游戏板,你就会明白。出于某种原因,只要我在正文中心放置一个文本区域,它就会与左右正文 div 重叠。问题发生在使用“con”类的 div 部分的某个地方。

这是问题的图片: http: //s8.postimage.org/fvlt9qi51/Dialog_Overlap.jpg

编辑:我设法通过在 CSS 的 .con 部分中将 height: 100% 替换为 height: 175px 来使其工作。我不明白为什么看起来不错,但 height: 100% 却不行?包含构成对话框的所有子 div 的顶级 div 具有以像素为单位指定的尺寸,对话框页眉和页脚也是如此。为什么中间也必须指定一个精确的值?我不想这样做,因为这意味着我需要为每个对话框设置一个特殊的 CSS 类,以便可以将特定的高度值添加到对话框的中间。

HTML在下面,CSS在后面。

    <div class="ttl">
        <div class="ttlt">
            <div class="ttlt-l"></div>
            <div class="ttlt-m">
                <a class="close" href="javascript:void(0);" onclick="cancelNotes();this.blur();return false;"></a>
                <span>Create Note</span>
            </div>
            <div class="ttlt-r"></div>
        </div>
        <div class="ttlb">
            <div class="ttlb-l"><span></span></div>
            <div class="ttlb-m"><span></span></div>
            <div class="ttlb-r"><span></span></div>
        </div>
    </div>

    <div class="con">
        <div class="con-l"></div>
        <div class="">
            <input type="hidden" id="hdnNoteID" />
            <textarea id="txtNote" rows="11" cols="50"></textarea>
        </div>
        <div class="con-r"></div>
    </div>

    <div class="ftr">
        <div class="ftr-l"></div>
        <div class="ftr-m">
            <a onclick="cancelNotes();this.blur();return false;" href="javascript:void(0);" class="btn"><span>Cancel</span></a>
            <a onclick="addNotes();this.blur();return false;" href="javascript:void(0);" class="btn"><span>Add Note</span></a>
        </div>
        <div class="ftr-r"></div>
    </div>

CSS

/* Title Bar */

.ttl { width:100%;height:38px; }

    /* Close button */
    .ttl a { margin-top:4px;display:block;float:right;width:23px;height:21px;background:transparent url("img/dialog/static.png") no-repeat -18px 0;cursor:default; }
    .ttl a:hover { background-position:-18px -21px; }
    .ttl a:active { background-position:-18px -42px;outline:none; }

    .ttlt { width:100%;height:30px; }
        .ttlt-l { width:9px;height:30px;background:transparent url("img/dialog/static.png") no-repeat;float:left; }
        /* ttlt-m width is dialogue width (450px) - 18px (the left & right divs are 9px each) */
        .ttlt-m { width:432px;height:30px;background:#000 url("img/dialog/horizontal.png") repeat-x;float:left; }
        .ttlt-mWide { width:632px;height:30px;background:#000 url("img/dialog/horizontal.png") repeat-x;float:left; }
        .ttlt-mExtraWide { width:930px;height:30px;background:#000 url("img/dialog/horizontal.png") repeat-x;float:left; }
        .ttlt-r { width:9px;height:30px;background:transparent url("img/dialog/static.png") no-repeat -9px 0;float:left; }
    .ttlt span { cursor:inherit;margin-left:4px;line-height:30px;color:#fff;font-weight:bold;font-family:Tahoma,"Lucida Grande",Verdana,Arial,Helvetica,sans-serif;font-size:11px; }

    .ttlb { width:100%;height:8px; }
        .ttlb span { display:none; }
        .ttlb-l { width:9px;height:8px;background:#000 url("img/dialog/static.png") no-repeat 0 -30px;float:left; }
        /* ttlb-m width is dialogue width (450px) - 18px (the left & right divs are 9px each) */
        .ttlb-m { width:432px;height:8px;background:#fff url("img/dialog/horizontal.png") repeat-x 0 -67px;float:left; }
        .ttlb-mWide { width:632px;height:8px;background:#fff url("img/dialog/horizontal.png") repeat-x 0 -67px;float:left; }
        .ttlb-mExtraWide { width:930px;height:8px;background:#fff url("img/dialog/horizontal.png") repeat-x 0 -67px;float:left; }
        .ttlb-r { width:9px;height:8px;background:#000 url("img/dialog/static.png") no-repeat -9px -30px;float:left; }

        .tabbed .ttlb-l { background-position:0 -38px; }
        .tabbed .ttlb-m { background-position:0 -75px; }
        .tabbed .ttlb-r { background-position:-9px -38px; }



/* Body */
.con { width:100%;height:100%;background-color:#fff;font-family:Tahoma,"Lucida Grande",Verdana,Arial,Helvetica,sans-serif;font-size:11px; cle}
    .con-l { width:9px;height:100%;background:#000 url("img/dialog/vertical.png") repeat-y;float:left; }
    /* con-m width is dialogue width (450px) - 18px (the left & right divs are 9px each) */
    .con-m { width:432px;height:100%;background-color:#fff;float:left; }
        .con-m .top { margin-top:2px; }
    .con-mWide { width:632px;height:100%;background-color:#fff;float:left; }
    .con-mExtraWide { width:930px;height:100%;background-color:#fff;float:left; }
    .con-r { width:9px;height:100%;background:#000 url("img/dialog/vertical.png") repeat-y -9px 0;float:left; }



/* Dialogue footer */
.ftr { width:100%;height:37px;font-family:Tahoma,"Lucida Grande",Verdana,Arial,Helvetica,sans-serif;font-size:11px; clear: left;}
    .ftr-l { width:9px;height:37px;background:transparent url("img/dialog/static.png") no-repeat 0 -75px;float:left; }
    /* ftr-m width is dialogue width (450px) - 18px (the left & right divs are 9px each) */
    .ftr-m { width:432px;height:37px;background:#eee url("img/dialog/horizontal.png") repeat-x 0 -30px;float:left; }
    .ftr-mWide { width:632px;height:37px;background:#eee url("img/dialog/horizontal.png") repeat-x 0 -30px;float:left; }
    .ftr-mExtraWide { width:930px;height:37px;background:#eee url("img/dialog/horizontal.png") repeat-x 0 -30px;float:left; }
    .ftr-r { width:9px;height:37px;background:transparent url("img/dialog/static.png") no-repeat -9px -75px;float:left; }
4

1 回答 1

0

如果没有接触到真实的东西,很难在那里提供帮助。

挡块.con及其左右部分都有height:100%。仅当它们的父级具有以像素为单位的高度时,这才有效。现在这个左右部分是不可见的,因为它们的高度为 0。如果您为此块的外部 div 提供 html 和 css 会更简单。尝试为其设置固定高度,例如 300px。

我也可以建议肮脏的解决方法。在您的样式后添加此 css:

.con {
  border:9px solid #000;
  border-width:0 9px;
  padding:0 9px;
  width:auto;
}
于 2013-01-11T23:05:38.907 回答