[CSS]左寄せ・右寄せで横に並べます

この記事は約2分で読めます。

 カミュプリィのホームページの上部にある『カミュプリィ』は左寄せ、『個人情報保護方針』は右寄せになっています。

HTML

<div class="top">
<div class="commuply"><a href="./index.html">カミュプリィ</a></div>
<div class="privacypolicy"><a href="./aboutus/privacypolicy.html">個人情報保護方針</a></div>
</div>

CSS

.top {
display: flex;
justify-content: space-between;
}

.top div {
margin: 0 1rem; /* 外側の余白: 上下左右*/
list-style: none;
height: 2rem;
line-height: 2rem;
text-align: center; /* 文字の位置: 中央寄せ */
}

.top .commuply {
text-align: left;
}

.top .privacypolicy {
text-align: right;
}
タイトルとURLをコピーしました