【问题标题】:Line not breaking correctly线路未正确断开
【发布时间】:2014-09-04 12:13:15
【问题描述】:

我遇到了换行问题。正如您在屏幕截图 1 中看到的那样,文本很好,但是当浏览器被拉下时(屏幕截图 2),文本会在随机点中断,而不是按单词留下大的空白。理想情况下,我希望每个单词都在需要时删除,而不是同时删除所有四个单词。

此 div 上没有填充或边距。我尝试了以下自动换行变量:正常、断词、初始和继承。我也尝试过 white-space: normal, no-wrap, pre, initial & inherit 但没有成功。

HTML/PHP:

<div class="full bottom-position">

    <div class="half right">

        <?php if ( get_sub_field('client_name') ) : ?>

              <span class="left-span">Client:</span>
              <span class="right-span"><?php the_sub_field('client_name'); ?></span>

        <?php endif; ?>


        <?php if ( get_sub_field('date') ) : ?>

              <span class="left-span">Date:</span>
              <span class="right-span"><?php the_sub_field('date'); ?></span>

        <?php endif; ?>


        <?php if ( get_sub_field('version') ) : ?>

              <span class="left-span">Version:</span>
              <span class="right-span"><?php the_sub_field('version'); ?></span>

        <?php endif; ?>


        <?php if ( get_sub_field('print') ) : ?>

              <span class="left-span">Print:</span>
              <span class="right-span"><a href="<?php the_sub_field('print'); ?>">Download presentation as PDF</a></span>

         <?php endif; ?>

     </div>

</div>

CSS:

.left-span {
    width: 15%;
    float: left;
}

.right-span {
    width: 85%;
    float: left;
}

.half {
    width: 50%;
    height: auto;
}
.right {
    float: right;
}

这是我以前从未遇到过的奇怪问题。任何帮助将不胜感激,谢谢。 小提琴可以在这里找到:http://jsfiddle.net/qkt93epw/

【问题讨论】:

  • 你能把代码贴出来吗?
  • word-wrap: break-word;?.
  • 你能fiddle你的代码吗?
  • @PraveenKumar 代码已发布。
  • @holloway 小提琴也适合我。有没有可能  正在使用而不是标准空间?

标签: css


【解决方案1】:

你可以试试吗?我给出的例子对我有用。

您已经为 span 提供了显示块。

span {
    width:10px; /*You can change your width*/
    white-space: normal;
    display:block;
}

HTML

<span>
    This is test. This is test.. This is test.. This is test.. This is test.. This is test.. This is test.. This is test.. This is test.. This is test.. This is test.
</span>

【讨论】:

  • 感谢您的帮助,但这是 Wordpress 后端的格式错误。
【解决方案2】:

客户端在导致错误的 Wordpress 后端中错误地格式化了文本(不确定如何)。我只是完全删除了他们的文本并重新输入它以删除现在有效的格式。感谢@HiddenHobes 的提醒和所有试图提供帮助的人。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-12
    • 2017-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-04
    相关资源
    最近更新 更多