html - 使用 css flexbox 缺少链接和段落之间的间隙

标签 html css flexbox

<分区>

我是第一次使用 css flexbox,我正在为我的页脚创建一个带有链接的段落,即

<p class="footer--credit">link 2 <a href="#">company</a>.</p>

Flexbox 以某种方式消除了链接 2 之后的空隙,请参见此处

body{
  background: red;
}.footer__contents {
    width: 100vw;
    height: 70px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    color: $white;
    background:pink;
}
a {
        color: $orange;
        text-decoration: none;
}
p {
        display: flex;
        align-items: center;
        justify-content: center;
}
<div class="footer__contents">
  <p class="footer--credit">link 2 <a href="#">company</a>.</p>
  <p class="footer--credit">link 1 <a href="#">company</a>.</p>
</div>

有什么想法吗?

最佳答案

添加white-space: pre-wrap;

body{
  background: red;
}.footer__contents {
    width: 100vw;
    height: 70px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    color: $white;
    background:pink;
}
a {
        color: $orange;
        text-decoration: none;
}
p {
        display: flex;
        align-items: center;
        justify-content: center;
        white-space: pre-wrap;
}
<div class="footer__contents">
  <p class="footer--credit">link 2 <a href="#">company</a>.</p>
  <p class="footer--credit">link 1 <a href="#">company</a>.</p>
</div>

关于html - 使用 css flexbox 缺少链接和段落之间的间隙,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55476285/

相关文章:

javascript - 返回元素类型

javascript - jQuery UI 弹跳效果对齐 Firefox 和 IE8 中剩余的元素

jquery - 使嵌套链接系统在悬停在其他 <li> 上时更改为 <li> bg

html - 如何更改 flexbox 列中元素的顺序?

css - 居中 v-toolbar-title

html - 有什么方法可以使用 DIV 实现动态内容的 TD 水平对齐?

html - 在 div 中居中按钮

.net - 类似于 iPad Facebook 应用的 CSS3 输入

html - 如何在不声明位置的情况下将元素放置在页面底部?

html - 在 flexbox 中组合不同的垂直对齐方式