【问题标题】:I can't align my div's next to eachother我无法将我的 div 彼此相邻对齐
【发布时间】:2013-06-16 13:10:43
【问题描述】:

我有 2 个 div,它们在一个 div 中。就像在代码中一样:

HTML:

    <div class="main" style="clear: both;">
        <div class="text">
        /text is here
        </div>    
        <div class="sponsors">
            <img src="images/Sponsors/asfalpan.png" alt="Asfalpan" width="285">
        </div>
    </div>

CSS:

.main {
    width: 1000px;
    margin-left: auto;
    margin-right: auto;
    position:relative;
    background-color:#232021;
    border-radius: 50px;
}
.text {
    width: 700px;
    padding-left:10px;
    padding-top: 20px;
    padding-bottom: 20px;
    position:relative;
    font-family: Gisha;
    color: white;
    font-size:14px;
 }
.sponsors {
    margin-left: 710px;
    margin-top: 20px;
    position: relative;
    font-family: Gisha;
    color: white;
    font-size: 14px;
    background-color: #E5173E;
}

所以我希望 .sponsors 和 .text 在 .main 中彼此相邻 但由于某种原因,这不会发生。他们出现在彼此之下。我该如何解决这个问题?

【问题讨论】:

    标签: image html alignment next


    【解决方案1】:

    为它们中的每一个添加float:left;,也许还有一个宽度

    DEMO

    在这里了解更多......

    http://css-tricks.com/all-about-floats/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-06
      • 1970-01-01
      • 2018-07-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多