【问题标题】:How to prevent cell table data to wrap in this case?在这种情况下如何防止单元格表数据换行?
【发布时间】:2018-02-26 01:38:37
【问题描述】:

在这张捕获的图像中:

页面代码为:

<div align="center">
<table cellpadding='1' cellspacing='1' width='98%' class="formulaire">
    <tr>
        <td width="5%"><img style="cursor:pointer"  id="img_rech"  width="16px" border="0" title="<?php echo _getText('main.recherche') ?>"  src="<?php echo HTTP_ICONES ?>ic_zoom.png" onclick="afficherRech()"></td>
        <td width="75%" class="normaltext" align="center">
            <input type="hidden" id="nb_total" value="<?php echo $data['event']['cnt']; ?>" />
            <span id="nb_enreg"></span><span id="total_enreg"><?php echo $data['event']['cnt'] . " " . _getText('main.accueil.evenement'); ?></span>
        </td>
        <td class="normaltext" width="10%" align="right"><span id="labelFiltre"><?php echo _getText('main.accueil.onglet.evenement.filtre'); ?></span></td>
        <td width="10%" align="right">
        <select id="filtreList" name="filtreList" onchange="filtrerList(this.value)" class="selectnormalCourt">
            <option value="-1"><?php echo _getText('main.accueil.onglet.evenement.filtre.tous'); ?></option>
            <option value="05">5</option>
            <option value="10">10</option>
            <option value="20">20</option>
            <option value="25">25</option>
            <option value="50">50</option>
        </select>
        </td>
    </tr>
</table>
</div>

列表框事件的JQuery是:

<script language="javascript">
    function filtrerList(nb_rows)
    {
        var nb_total = $('#nb_total').val();
        var num = new Number(nb_rows); // pour ne pas afficher le "0" avant le chiffre ( 05 )
        nb_total = new Number(nb_total);
        if (num != -1)
        {
            if (nb_rows > nb_total)
            {
                $('#nb_enreg').html(nb_total + ' sur ');
            }
            else
            {
                $('#nb_enreg').html(num + ' sur ');
            }
        }
        else
        {
            $('#nb_enreg').html('');
        }

        var html = $.ajax({
            data: "nb_rows="+nb_rows+"&mp="+<?php echo $_SESSION[MANUEL]; ?> ,
            type: "POST",
            url:  "<?php echo HTTP_AJAX_REF ?>ReferentielFiltrerListEventsAjax.php",
            async: false
         }).responseText;
        $('#list').html(html);
    }
</script>

如何去掉我用红色圈起来的换行符?

这里是 CSS:

.formulaire {
    border: 0px solid;
    border-color:#b80500;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
}

.normaltext{
    width:150px;
    font-family: Verdana, Helvetica, sans-serif;
    font-size:11px;
    font-weight:bold;
    color:#000;
}

.formulaire .selectnormalCourt {
    width: 63px;
    background-color:#FFFF; 
    border:1px solid;
    border-color:#b80500;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
    border: 1px solid #bbb;
    color: #000;
    background-position: 10px 6px;
    float: right;
}

.formulaire .selectnormalCourt:focus {
    outline: none;
    border: 1px solid #699DE3;
    -webkit-box-shadow: inset 0 2px 2px #ccc, 0 0 10px #ADDCE6;
    -moz-box-shadow: inset 0 2px 2px #ccc, 0 0 10px #ADDCE6;
    box-shadow: inset 0 2px 2px #ccc, 0 0 10px #ADDCE6;
    color: #666666;
}

【问题讨论】:

    标签: jquery html html-table


    【解决方案1】:

    从发布的代码中并不清楚文本是如何生成的,但您应该简单地确定哪个元素将包含文本“5 sur 13 événements”或类似的内容,并在 CSS 中设置white-space: nowrap。如果这破坏了布局,请重新设计布局以适应文本。

    【讨论】:

    • 在文本“5 sur 13 événements”中:“5 sur 13”写入第一个span元素,“13 événement”写入第二个span元素。
    • @Pheromix,然后需要一个额外的 span 元素围绕它们。
    • 我写了这个:&lt;span style="white-space:nowrap"&gt;&lt;span id="nb_enreg"&gt;&lt;/span&gt;&lt;span id="total_enreg"&gt;&lt;?php echo $data['event']['cnt'] . " " . _getText('main.accueil.evenement'); ?&gt;&lt;/span&gt;&lt;/span&gt; 但换行符并没有消失!
    • @Pheromix,我认为您需要发布示例代码,由实际的 HTML 和 CSS 代码组成(与生成 HTML 的 PHP 代码相反)。或者,一个 URL 可能有用。
    猜你喜欢
    • 1970-01-01
    • 2023-04-03
    • 2015-09-26
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    • 2020-03-18
    • 2018-10-16
    • 1970-01-01
    相关资源
    最近更新 更多