简体   繁体   English

HTML<P> 没有溢出到换行符

[英]HTML <P> is not overflowing to newline

I try to create a kanban, and i have trouble getting text to overflow to the next line.我尝试创建看板,但无法让文本溢出到下一行。 I tried我试过

overflow-wrap: break-word;
word-wrap: break-word;
hyphens: auto;

and i tried all other styling for breaking to a new line, and none are working.我尝试了所有其他样式以换行,但都没有工作。 preview预览

Iuse vuejs, but i doubt this has anything to do with it.我使用 vuejs,但我怀疑这与它有什么关系。 I tried everything i could find, but none works.我尝试了所有我能找到的方法,但没有一个奏效。 I dont know if the parent needs any styling set for this to work?我不知道父母是否需要任何样式设置才能使其工作? Someone who can help me out?谁能帮帮我?

css: css:

.kanban-card {
    display: block;
    position: relative;
    overflow: hidden;
    min-height: 100px;
    width: 100%;
    border-radius: calc(0.15rem - 1px);
    @include depth(1);
    background: $foreground-color;
    border: 1px solid darken($foreground-color, 10%);
    .kanban-type-icon {
        position: absolute;
        top: 0;
        left: 0;
        width: 30px;
        height: 28px;
        border-bottom-right-radius: 30px;
        background-color: $theme-color-1;
        i {
          color: #fff;
          position: absolute;
          top: 5px;
          left: 5px;
        }
    }
    .kanban-type-border {
        position: absolute;
        width: 3px;
        top: 0;
        bottom: 0;
        left: 0;
        background-color: $theme-color-1;
    }
    .kanban-content {
        display: block;
        width: 100%;
        overflow: hidden;
        text-indent: 1em;
        p {
            max-width: 200px;
            margin: 0;
        }
    }
}

and vue:和 Vue:

<template>
<div class="kanban-card px-3 py-3">
    <span class="kanban-type-icon">
        <i class="simple-icon-bell" />
    </span>
    <span class="kanban-type-border"></span>
    <div class="kanban-content">
        <p>hier een lange zin om te zien of deze pastier een lange zin om te zien of deze pastier een lange zin om te zien of deze pastier een lange zin om te zien of deze past</p>
        <p>hier een lange zin om te zien of deze past</p>
        <p>hier een lange zin om te zien of deze past</p>
        <p>hier een lange zin om te zien of deze past</p>
    </div>
</div>
</template>
<script>
    export default {
        props: ['board'],
        components: {

        },
        data () {
          return {
            scrollSettings: {
              suppressScrollX: true, 
              wheelPropagation: false,
              swipeEasing: true
            }
          }
        }
    };
</script>

after removing the missing mixin your example wraps properly, so the issue probably stems from something outside of what you've shared.删除缺少的 mixin 后,您的示例将正确包装,因此问题可能源于您共享的内容之外的内容。

that being said...话虽如此...

  • the <i> is not a self closing tag and this could be causing some of your problems. <i>不是自结束标记,这可能会导致您的一些问题。
  • using an absolute positioned empty <span> to create a border is not the best solution and could cause more problems使用绝对定位的空<span>来创建边框不是最好的解决方案,可能会导致更多问题

see if this works better for you:看看这是否更适合你:

<div class="kanban-card">
  <span class="kanban-type-icon">
    <i class="fa fa-bell"></i>
  </span>
  <div class="kanban-content">
    <p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo.</p>
    <p>Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. </p>
    <p>Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem.</p>
  </div>
</div>
.kanban-card {  
  background: $foreground-color; 
  position: relative;
  padding: 1.5em 1em;

  border-left: solid 3px $theme-color-1;
  border-top: solid 3px $theme-color-1;

  .kanban-type-icon {
      background-color: $theme-color-1;
      width: 2em;
      height: 2em;
      border-bottom-right-radius: 100%;
      position: absolute;
      top: 0;
      left: 0;
      i {
        color: #fff;
        margin-left: 6px;
        margin-top: 6px;
      }
  }
  .kanban-content {
      p {
        text-indent: 1em;
        margin-bottom: 1em;
      }
  }
}

Codepen Example代码笔示例

You need to add width to parent HTML attribute, in your case <div> and add this CSS property to your <p>您需要为父 HTML 属性添加宽度,在您的情况下为<div>并将此 CSS 属性添加到您的<p>

word-break: break-all

 <p style="width: 50px; word-break: break-all"> testefdsfsdfdsfsdfsdfdssdfsdfdsfdsfsdfsdfdfd</p>

Demo here演示在这里

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

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