亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在彎曲方向垂直居中:列

在彎曲方向垂直居中:列

青春有我 2023-12-19 10:54:46
我正在嘗試使用 Flexbox 將頁面左側的元素垂直居中,但無法弄清楚。它們是通過 flex-direction: column 組織的,我不確定設置后如何水平居中。請參閱下面的我的代碼和到目前為止我的網站的實時版本。我將兩個彈性容器分成左右兩部分,這樣我就可以分別處理它們并將它們居中。目前我只處理左側。因此,我將首先展示它的 CSS。我嘗試過 align-items、justify-content 和 align-self,但這些都不起作用。提前致謝!實時網站:https://huddle-single-landing-page.jordanchude.now.sh/超文本標記語言<div class="container"><div class="left-side">  <img id="huddle" src="https://i.ibb.co/FnJS8vM/logo.png" alt="logo" border="0">  <img id="illustration" src="https://i.ibb.co/L9HBmDZ/illustration-mockups.png" alt="illustration-mockups" border="0"></div><div class="right-side">  <p id="headline">Build The Community Your Fans Will Love</p>  <p id="subtitle">          Huddle re-imagines the way we build communities. You have a voice, but so does your audience.           Create connections with your users as you engage in genuine discussion.  </p>   <button>Register</button>  <div class="social-icons">    <span class="fa-stack fa-lg">        <i class="far fa-circle fa-stack-2x"></i>        <i class="fab fa-facebook-f fa-1x"></i>    </span>    <span class="fa-stack fa-lg">        <i class="far fa-circle fa-stack-2x"></i>        <i class="fab fa-twitter fa-1x"></i>    </span>    <span class="fa-stack fa-lg">        <i class="far fa-circle fa-stack-2x"></i>        <i class="fab fa-instagram fa-1x"></i>    </span>  </div></div>CSS .container {    display: flex;    flex-direction: row;    justify-content: space-around;    flex-wrap: wrap;}/* Left Side */.left-side {    display: flex;    flex-direction: column;     width: 800px;}#huddle {    width: 200px;    align-self: flex-start; }#illustration {   width: 100%; }
查看完整描述

1 回答

?
飲歌長嘯

TA貢獻1951條經驗 獲得超3個贊

您的容器中沒有額外的高度,因此沒有用于居中的可用空間。


進行此調整:


.container {

    display: flex;

    flex-direction: row;

    justify-content: space-around;

    /* align-items: center */ /* vertically centers both left and right elements */

    flex-wrap: wrap;

    height: 100vh; /* child would inherit height through align-content: stretch default */

}


.left-side {

    display: flex;

    flex-direction: column;

    width: 800px;

    align-self: center; /* vertically centers the flex item */        

    /* justify-content: center; */ /* vertically centers the content of the flex item */

}


查看完整回答
反對 回復 2023-12-19
  • 1 回答
  • 0 關注
  • 155 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號