在旁边放两个div。一个居中,一个偏离中心到右边

时间:2018-06-13 11:29:48

标签: html css

我想把两个div放在一起。一个居中,一个居中但向右偏移。这不是重复,因为我不想将第二个div对齐。我需要将它与中心偏移对齐。 this is how it should look 这是我的代码,我不能让文本垂直对齐,也不能使第一个div居中。

HTML:

<div class="consents-container">
    <div class="consent-container">
        <div class="consent-text">
            This is a long all centered text<\br>
            with two lines
        </div>
        <div class="consent-interaction">
            This is X Pixels offst to the right from center
        </div>
    </div>
    <div class="consent-container">
        <div class="consent-text">
            This is a long all centered text<\br>
            with two lines
        </div>
        <div class="consent-interaction">
            This is X Pixels offst to the right from center
        </div>
   </div>
</div>

CSS:

.consents-container{
    z-index: 10000;
    width: 100%;
}

.consent-container{
    width: 100%;
    background-color: #FBBB01;
    margin-bottom: 2px;
    min-height: 50px;
}

.consent-text{
    background-color: blue;
    display: inline-block;
    width: 40%;
    line-height: normal;
}

.consent-interaction{
    background-color: red;
    display: inline-block;
    width: 20%;
}

0 个答案:

没有答案