简体   繁体   English

如何将这一行与 flexbox 对齐?

[英]How do I align this row with flexbox?

Im trying to get an image to be in the same row as my text in my ABOUT section.我试图让图像与我的关于部分中的文本在同一行。

I've tried to wrap my <div class="portrait"> and <p> into a <div class="wrapper"> with css flex-direction:row我试图用 css flex-direction:row将我的<div class="portrait"><p> <div class="wrapper">成一个<div class="wrapper">

Heres a pen: https://codepen.io/anon/pen/MqRdjb Heres a pen: https Heres a pen: //codepen.io/anon/pen/MqRdjb

I think some CSS is being overwritten, or I'm not using my CSS properly.我认为某些 CSS 被覆盖,或者我没有正确使用我的 CSS。

Thanks for any and all help!!感谢您的任何帮助!

flex-direction: row has no effect without including display: flex . flex-direction: row在不包含display: flex情况下无效。

Adjust the wrapper css to:将包装器 css 调整为:

.wrapper {
  flex-direction: row;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

You can also refactor the margins for the elements inside the wrapper if you want to center them.如果您想将它们居中,您还可以重构包装器内元素的边距。 Any vertical margins can be removed and applied to the wrapper itself.可以移除任何垂直边距并将其应用于包装器本身。

.portrait{
  width:100px;
  height:150px;
  margin-left: auto;
  margin-right: 10px; /* Align your image right */
  z-index: 1;
  border-radius: 10%;
  background-color:#555;
}

.ABOUT p{
  font-size:1.2em;
  text-align: center;
  margin-right: auto; /* align text left */
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM