1

我正在修改 magento 中的现代主题,使其宽度达到 1280 像素。

一切似乎都在工作,除了当左列是固定宽度并且主列扩展以填充其余空间时,我无法让左列和主列(在 2 列左布局中)内联显示。我让它工作的唯一方法是绝对定位左列,这不允许包装器再用左列内容扩展。

希望这有点道理。无论如何,这是我目前正在使用的临时绝对定位修复的 HTML 和 css。我尝试过使用浮点数和内联块以及通过谷歌找到的其他一些方法,但似乎都没有。问题 div 是 col-left 和 col-main。

任何帮助将不胜感激。

HTML:

    <div class="page">

        <div class="main-container col2-left-layout">

            <div class="main">
                <?php echo $this->getChildHtml('breadcrumbs') ?>
                <div class="col-left sidebar"><?php echo $this->getChildHtml('left') ?></div>
                <div class="col-main">
                    <?php echo $this->getChildHtml('global_messages') ?>
                    <?php echo $this->getChildHtml('content') ?>
                </div>
        <div style="clear:both"></div>

            </div>

        </div>

        <?php echo $this->getChildHtml('footer') ?>
        <?php echo $this->getChildHtml('before_body_end') ?>

    </div>

CSS

.page { width:80%; margin:15px auto 0; text-align:left; min-width:960px; max-width: 1280px;position:relative;}
.main-container {position:relative;float:left;clear:both;}
.main { background:#fff; border:1px solid #bbb;position:relative;float:left; padding-top:10px;width:100%;}

/* Base Columns */
.col-left { width:220px;float:left;position:absolute; left:10px;top:10px;z-index:1000;}
.col-main {  padding:0px 10px 10px 220px; float:left; margin-left:20px; }
.col-right { float:right; width:220px; padding:0 0 1px; }
4

1 回答 1

0

我似乎记得很久以前做过这样的事情,解决方案非常复杂。使用负边距等。幸运的是,我认为我找到了关于 smasingmag 的文章,它解释了如何做到这一点 - 您可能需要更改它,因为示例将正文设置为 80%,但我认为这个想法应该适用于全角网站。希望这可以帮助:

http://coding.smashingmagazine.com/2010/11/08/equal-height-columns-using-borders-and-negative-margins-with-css/

于 2012-06-15T18:13:52.760 回答