MDBootstrap手机端pre,code标签不支持横向滚动

代码


<!DOCTYPE html>
<html>
    <head>
        <title>Index</title>
        <meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        <link rel="stylesheet" type="text/css" href="static/library/bootstrap/5.1.3/css/bootstrap.min.css">
        <script type="text/javascript" src="static/library/bootstrap/5.1.3/js/bootstrap.min.js"></script>
    </head>
    <body>
        <style type="text/css">
            #d1,
            #d2 {
                overflow: scroll;
                width: 300px;
                border: 1px solid red;
            }

            /* pre,
            code {
                unicode-bidi: normal !important;
            } */
        </style>
        <div id="d1">
            d1-000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
        </div>
        <div id="d2">
            <pre>
<code>d2-000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000</code>
                    </pre>
        </div>
    </body>
</html>




在pc段呈现正常, 可以横向滚动
image.png

以下是手机端呈现, 自动换行了, 不能横向滚动

image.png

确定是引入了bootstrap导致的问题, 如果去除框架的依赖后可以正常的横线滚动
如何解决这个问题? 如果需要用bootstrap并且手机端pre,code支持横向滚动

阅读 1k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏