简体   繁体   English

div内部的div未按预期对齐

[英]Div inside div not aligning as expected

You can visit the site I am trying to work on here . 您可以在这里访问我正在尝试的站点。

I am trying to get basically the layout as in the top right box in the bottom right box, but for some reason I cannot get it to float to the right. 我试图基本上获得右下角框中右上角的布局,但是由于某种原因,我无法使其浮动到右侧。 Is there something I am missing here? 我在这里缺少什么吗? It's driving me nuts because my code works in the upper box but not in the lower one. 这让我发疯了,因为我的代码在上面的框中起作用,而在下面的框中不起作用。

Here's the HTML. 这是HTML。

<div id="menu-ad">
        <div>
            <p class="titles">Our Fare</p>
            <p id="ad">Our lunch and dinner menus feature European inspired comfort food accompanied by an extensive bar.</p>
            <a href="#" id="button">VIEW MENU</a>
        </div>
    </div><!--end menu ad-->

    <div id="hours">
        <div>
        </div>
    </div><!--end hours-->
</div><!--end container-->

And the CSS. 还有CSS。

/*menu ad*/

div#menu-ad {
    position: relative;
    margin-right: -11px;
    margin-top: -11px;
    width: 268px;
    height: auto;
    float: right;
    padding: 11px 11px 10px 10px;
    border-left: 2px solid #b9aea3;
    border-bottom: 2px solid #b9aea3;
    overflow: hidden;
}

div#menu-ad div {
    background: #f9f4df;
    padding: 1.9rem 4rem 2.5rem 2.5rem;
    height: 200px;
    display: inline-block;
}

.titles {
    font-family: "Montserrat", "Helvetica", sans-serif;
    font-size: 2.5rem;
    color: #d6832e;
}

#ad {
    font-family: "Montserrat", "Helvetica", sans-serif;
    font-size: 1.6rem;
    line-height: 1.35;
    color: #4f4d4b;
    margin-top: .5rem;
    width: auto;
}

a#button {
    padding: .6rem 1.3rem .6rem 1.3rem;
    font-family: "Montserrat", "Helvetica", sans-serif;
    font-size: 1.8rem;
    color: #fff;
    background: #d6832e;
    text-align: center;
    vertical-align: middle;
    text-decoration: none;
    position: absolute;
    float: left;
    bottom: 3.5rem;
}

/*hours*/

div#hours {
    position: relative;
    margin-right: -11px;
    margin-top: 11px;
    width: 268px;
    height: auto;
    float: right;
    padding: 11px 11px 10px 10p;
    border-left: 2px solid #b9aea3;
}

div#hours div {
    background: #f9f4df;
    padding: 1.9rem 4rem 2.5rem 2.5rem;
    height: 150px;
    display: inline-block;
}

Thanks for any help! 谢谢你的帮助! It's probably something simple and I just need a fresh pair of eyes. 这可能很简单,我只需要一双新鲜的眼睛。

you seem to have a typo, 您似乎有错字,

under the style rule for 根据样式规则

div#hours

you have 你有

padding: 11px 11px 10px 10p;

your missing an 'x' at the end. 您最后缺少一个“ x”。 Which means the padding rule is not being applied 这意味着未应用填充规则

Now this solves the alignment, but the height might not be right now, but I'm sure that should be straight forward 现在这解决了对齐问题,但是高度可能不是现在,但是我敢肯定应该是直截了当的

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

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