简体   繁体   English

如何修复 flex-direction: column 如何让前两个元素是行方向最后一列的 flex

[英]How to fix flex-direction: column How to have a flex that the first two elements are row direction the last column

I'm trying to build a div that does the following: On the left, there is a date.我正在尝试构建一个执行以下操作的 div:在左侧,有一个日期。 Next to it is an edit button.它旁边是一个编辑按钮。 Under these two elements, I have some text.在这两个元素下,我有一些文字。 I'm not able to get the text under the two elements.我无法获取这两个元素下的文本。

I was using flex to achieve this and I broke each element into a separate div.我使用 flex 来实现这一点,并将每个元素分解为一个单独的 div。 The last elements I used flex-direction: column;我使用的最后一个元素 flex-direction: column; to make sure it goes under the first two.以确保它在前两个之下。

However with no success.然而并没有成功。

 /* _________________________ This is the containers for my_thought page */ #blocks { display: flex; margin: 10px; } #blocks div{ flex: 0 0 100px; padding: 10px 0; text-align: center; } .one{order: 0;}; .two{order: 1;}; .three{ order: 2; flex-direction: column; }; /*________________________ */
 <div class="Thoughts" id="blocks"> <div class="one"> <h2>Date: <?php $date = strtotime($row['date_created']); echo date('m/d/y', $date); ?> </h2> </div> <div class="justify-content-center .button .two"> <button type="submit" name="submit" class="btn btn-primary">Edit post</button> </div> <div class="three"> <br> <p> <?php echo $row['text']; ?> </p> </div>

I am attaching a photo showing how my code looks currently.我附上了一张照片,显示了我的代码目前的样子。 What am I doing wrong?我究竟做错了什么?

You can find a photo of the output the following link: https://drive.google.com/file/d/1Q90qE6mWHZtrcXnAXJdUuSUqHtHt31ig/view?usp=sharing您可以通过以下链接找到输出的照片: https : //drive.google.com/file/d/1Q90qE6mWHZtrcXnAXJdUuSUqHtHt31ig/view?usp=sharing

Thank you for the help.感谢您的帮助。 I was able to solve the problem.我能够解决这个问题。 I am showing the code I used solve the problem.我正在展示我用来解决问题的代码。

 #blocks { display: flex; margin: 10px; } #blocks div{ flex: 1 0 100px; padding: 1px 0; text-align: center; } .one{ order: 0; margin: 10px; }; .two{order: 1; margin: 10px; };
 <div class="Thoughts"> <div id="blocks"> <div class="one"> <h2>Date: <?php $date = strtotime($row['date_created']); echo date('m/d/y', $date); ?> </h2> </div> <div class="justify-content-center .button .two"> <button type="submit" name="submit" class="btn btn-primary">Edit post</button> </div> </div> <p> <?php echo $row['text']; ?> </p> </div>

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

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