dongping2023 2015-10-05 16:31
浏览 48
已采纳

PHP打印数据库中的选项卡

There's a simple way to include
when there's a new line in the database (nl2br), but is there anything similar for tabs?

I've tried different solutions which works in the way of the look, but not when you're copying the code. I've tried a CSS style and made it like:

#br{
margin-right: 30px;
float: left;
}

But once I copy the code, there's no tab. In my database there's a TAB, but how do I print the tab?

  • 写回答

2条回答 默认 最新

  • dshnx48866 2015-10-05 16:36
    关注

    You can use a bit of CSS to display tabs as tabs.

    #br {
       white-space: pre-wrap;
       tab-size: 4;
    }
    

    pre-wrap is the best solution, I think, because it still allows the text to wrap normally when a line is full. pre is also possible, but then the text won't break at the end of a line.

    tab-size is optional. By default it is set to 8 spaces, but you can change that by specifying a number of spaces in this property.

    Note that I've copied your CSS selector, #br, but normally I would make a class for this, so you can easily apply this style to any number of elements in your page.

    Also note, since pre-wrap also displays line breaks as actual breaks, you probably won't need to call nl2br on the server anymore.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c