简体   繁体   English

如何将一行文字移到另一个下方?

[英]How to move line of text below another?

I am having trouble moving one line of text below another. 我在将一行文字移动到另一行下方时遇到麻烦。 I have a feeling its something to do with the flexbox vertical align. 我觉得它与flexbox垂直对齐有关。 I have also tried using display: block but to no avail. 我也尝试过使用display: block但无济于事。 Please help, thank you. 请帮忙,谢谢。

The problem is the first section here: https://jsfiddle.net/sqeeux47/ 问题是这里的第一部分: https : //jsfiddle.net/sqeeux47/

HTML HTML

<section id="section1">
    <h1 id="section1heading">Welcome to our multicultural society.</h1>
    <h4 id="section1paragraph">Come worship with us.</h4>
</section>

CSS CSS

#section1 {
    background-image: url(" http://i300.photobucket.com/...");
    background-repeat:no-repeat;
    background-size:100%;
    background-position:center;
    width:100%;
    height:606px;
    text-align:center;
    display:flex;
    align-items:center;
    justify-content:center;
}

Add one line to the parent container: 在父容器中添加一行:

#section1 { flex-direction: column; }

OR 要么

#section1 { flex-wrap: wrap; }

When you create a flex container (by declaring display: flex on an element), several default rules go into effect. 创建Flex容器时(通过在元素上声明display: flex ),一些默认规则将生效。 Two of these rules are flex-direction: row and flex-wrap: nowrap . 其中两个规则是flex-direction: rowflex-wrap: nowrap

This means that flex items will align horizontally on a single line, which is the issue you are facing. 这意味着弹性项目将在一行上水平对齐,这是您面临的问题。

In order to alter this behavior, you could change the flex-direction or allow flex items to wrap. 为了更改此行为,您可以更改flex-direction或允许弹性项目包装。

如何将文本行移动到顶部<div></div><div id="text_translate"><p>关于图片所示的第 1 步,我如何将第一行向上移动“我的第一个项目”,以便继续行就在它的下方(如您在右侧看到的那样)?</p><p> <a href="https://codepen.io/simon-parker-the-decoder/pen/abZXPpR" rel="nofollow noreferrer">代码笔</a></p><p><a href="https://i.stack.imgur.com/tDM7C.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tDM7C.png" alt="解决方案的外观图像"></a></p><p> 谢谢</p><p> <strong>Html</strong></p><pre> <div class="list"> <div>My first item <br> My first item continued </div> <br> <div>My second item</div> <br> <div>My third item</div> </div></pre><p> <strong>CSS</strong></p><pre> div.list { counter-reset: list-number; } div.list div:before { counter-increment: list-number; content: counter(list-number); margin-right: 10px; margin-bottom:10px; width:35px; height:35px; display:inline-flex; align-items:center; justify-content: center; font-size:16px; background-color:#d7385e; border-radius:50%; color:#fff; } div.list div { color: purple; }</pre></div> - How to move text line to the top of <div>

暂无
暂无

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

相关问题 如何将文本移动到浮动元素下方的新行 - How to move text to a new line below floated elements 如何将此文本移动到另一行 - How to move this text onto another line 如何将某些文本下方的边框向下移动? - How to move a border below some text down? 如何使文本移动到JQuery幻灯片下方 - how to make text move below the JQuery slide 如何使用 CSS 将一个 HTML 元素移动到另一个元素下方 - How to move one HTML element below another with CSS 如何使用 css 中的边距属性将一个部分移动到另一个下方 - how to move a section below another using margin property in css 如何将文本移动到滑块箭头下方 - How can I move the text below the slider arrows 如何向下移动文本并在图片下方放置标题 - How to move text down and place a caption below a picture 如何将文本行移动到顶部<div></div><div id="text_translate"><p>关于图片所示的第 1 步,我如何将第一行向上移动“我的第一个项目”,以便继续行就在它的下方(如您在右侧看到的那样)?</p><p> <a href="https://codepen.io/simon-parker-the-decoder/pen/abZXPpR" rel="nofollow noreferrer">代码笔</a></p><p><a href="https://i.stack.imgur.com/tDM7C.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tDM7C.png" alt="解决方案的外观图像"></a></p><p> 谢谢</p><p> <strong>Html</strong></p><pre> <div class="list"> <div>My first item <br> My first item continued </div> <br> <div>My second item</div> <br> <div>My third item</div> </div></pre><p> <strong>CSS</strong></p><pre> div.list { counter-reset: list-number; } div.list div:before { counter-increment: list-number; content: counter(list-number); margin-right: 10px; margin-bottom:10px; width:35px; height:35px; display:inline-flex; align-items:center; justify-content: center; font-size:16px; background-color:#d7385e; border-radius:50%; color:#fff; } div.list div { color: purple; }</pre></div> - How to move text line to the top of <div> 更改行高时,单击一个按钮后,相邻按钮和按钮下方的文本向下移动 - On line-height change, adjacent buttons and text below buttons move down when one button is clicked
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM