css问题拉伸中间div圣杯

时间:2011-04-26 06:26:02

标签: html css layout

我似乎无法弄清楚为什么menu-item-middle类中的中间div(menuitem类)不会延伸。我现在花了很多时间在这上面,我觉得我最好发布这个,因为我无法弄清楚这一点。这就是我的代码。

.menu-item  div
{
    display:inline-block
}
.menu-item-left
{
    left:0px; float:left; border:1px solid #000000
}
.menu-item-middle
{
    padding-top:5px; padding-bottom:6px; padding-right:5px; left:39px; float:left; border:1px solid #000000
}
.menu-item-right
{
    width:26px; height:44px; right:0px; clear:right; background-image:url('images/Menu_Item_Arrow.jpg'); background-repeat:no-repeat; border:1px solid #000000
}
<table border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td>
            <div class="menu-item">
                <div class="menu-item-left">
                    <div class="item-corner">
                    </div>
                    <div class="item-icon">
                        <img alt="" height="36" src="images/spacer.gif" width="36" />
                    </div>
                </div>
                <div class="menu-item-middle">
                    <table border="0" cellpadding="0" cellspacing="0" style="margin-left:5px">
                        <tr>
                            <td>
                                <a href="#">
                                <span style="font-family:Verdana; font-size:.95em; font-weight:bold">Technology</span>
                                </a>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span style="font-family:Arial; font-size:.7em; color:#0b83bb">Computers &amp; 
                                Office Supplies</span></td>
                        </tr>
                    </table>
                </div>
                <div class="menu-item-right">
                    <img alt="" height="44" src="images/spacer.gif" width="26" />
                </div>
            </div>
            <div class="menu-item">
                <div class="menu-item-left">
                    <div class="item-corner">
                    </div>
                    <div class="item-icon">
                        <img alt="" height="36" src="images/spacer.gif" width="36" />
                    </div>
                </div>
                <div class="menu-item-middle">
                    <table border="0" cellpadding="0" cellspacing="0" style="margin-left:5px">
                        <tr>
                            <td>
                                <a href="#">
                                <span style="font-family:Verdana; font-size:.95em; font-weight:bold">Intersts</span>
                                </a>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span style="font-family:Arial; font-size:.7em; color:#0b83bb">Movies Books &amp; 
                                Music</span></td>
                        </tr>
                    </table>
                </div>
                <div class="menu-item-right">
                    <img alt="" height="44" src="images/spacer.gif" width="26" />
                </div>
            </div>
            <div class="menu-item">
                <div class="menu-item-left">
                    <div class="item-corner">
                    </div>
                    <div class="item-icon">
                        <img alt="" height="36" src="images/spacer.gif" width="36" />
                    </div>
                </div>
                <div class="menu-item-middle">
                    <table border="0" cellpadding="0" cellspacing="0" style="margin-left:5px">
                        <tr>
                            <td>
                                <a href="#" style="text-decoration:none; color:#0b83bb">
                                <span style="font-family:Verdana; font-size:.95em; font-weight:bold">
                                Entertainment</span> </a>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span style="font-family:Arial; font-size:.7em; color:#0b83bb">Software &amp; 
                                Digital Games</span></td>
                        </tr>
                    </table>
                </div>
                <div class="menu-item-right">
                    <img alt="" height="44" src="images/spacer.gif" width="26" />
                </div>
            </div>
        </td>
    </tr>
</table>

2 个答案:

答案 0 :(得分:1)

这是因为您设置了float属性。如果您想保留它,请尝试在课程中添加width: 100%

答案 1 :(得分:1)

我认为这是因为,div的内容与其他两个不同。您可以尝试使用

<强> CSS

.menu-item-middle {min-width:150px}

适用于IE8&amp; +