私はcontact-section-left
が親divにセンタリングしていない問題に遭遇しています。これはvertical-align: top
の問題ではありません。 border-right
白線は、contact-section-left
divの高さがどの程度伸びているかを示していますが、画像の右側と同じサイズになります(この例では画像がありません)。センタリングインラインブロックのdiv要素
私はここに間違ったアプローチをしようとしているのかどうか分かりませんが、私は下に作ったペイントイメージのように見せたいと思っています。
アイデア?左/右セクションの親にdisplay: flex; align-items: center;
をAssiging
.total-center {
text-align: center;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
#contact-section {
\t width: 100%;
\t background: #00a16d;
}
#contact-section-wrap {
\t padding: 2%;
}
#contact-section-left, #contact-section-right {
\t height: 100%;
\t display: inline-block;
\t color: #FFF;
\t font-size: 1.5em;
\t padding: 1% 0;
\t position: relative;
}
#contact-section-left {
\t width: 60%;
\t border-right: 1px solid #FFF;
\t font-style: italic;
}
#contact-section-right {
\t width: 30%;
\t text-align: center;
}
#contact-img {
\t background-image: url("../icons/envelope.png");
\t background-repeat: no-repeat;
\t background-size: auto;
\t margin: 0 auto;
\t display: block;
\t width: 128px;
\t height: 128px;
\t position: relative;
}
#contact-width {
\t width: 200%;
\t font-size: 2em;
}
.total-width {
\t width: 100%;
}
<div id="contact-section">
\t \t <div id="contact-section-wrap">
\t \t \t <div id="contact-section-left">
\t \t \t \t <div class="total-center total-width">Tell us more about your project.</div>
\t \t \t </div><div id="contact-section-right">
\t \t \t \t <div id="contact-img"><span class="total-center" id="contact-width">Contact us</span></div>
\t \t \t </div>
\t \t </div>
\t </div>
感謝。とにかく左側の 'border-right'白線を間に入れますか? – Paul
@Paul oh申し訳ありませんが、私の答えをもう一度チェックしてください。私はコピーして貼り付け、 'border-right'を' border-left'に変更するのを忘れました –
Perfect。助けてくれてありがとう! – Paul