V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Can I use?
http://caniuse.com/
Less
http://lesscss.org
Cool Libraries
Bootstrap from Twitter
Jetstrap
gouchaoer2
V2EX  ›  CSS

markdown 的 code 标签渲染成 html 的 css 问题

  •  
  •   gouchaoer2 · 2020-08-24 10:38:18 +08:00 · 1745 次点击
    这是一个创建于 1333 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我有个 css 问题,标签里的内容如果太长了会显示横的和竖的 scroll,能有办法去掉横的和竖的 scroll,然后如果某行 code 太长了就自动换行,问一下怎么做呢?

    比如这个页面拉到最下面那个 pdf 的 code 区块,我要去掉这个 scroll,把右边超出的地方换行: https://gitbookio.gitbooks.io/documentation/content/format/configuration.html

    8 条回复    2020-08-24 11:51:10 +08:00
    demo
        1
    demo  
       2020-08-24 10:43:01 +08:00
    pre > code {
    white-space: pre-wrap;
    }
    misaka19000
        2
    misaka19000  
       2020-08-24 10:45:30 +08:00
    white-space: initial;
    sixway
        3
    sixway  
       2020-08-24 10:53:32 +08:00
    一楼的可行。
    gouchaoer2
        4
    gouchaoer2  
    OP
       2020-08-24 11:05:52 +08:00
    @demo 好的,3q 我搞定了

    能顺便问一下么,我 gitbook 渲染成 html 用你的 css 是 ok 的,然后渲染成 pdf 的时候发现还是会渲染成袋 scroll 那种,我确定渲染成 pdf 的 css 是有效的
    gouchaoer2
        5
    gouchaoer2  
    OP
       2020-08-24 11:09:55 +08:00
    demo
        6
    demo  
       2020-08-24 11:20:46 +08:00
    @gouchaoer2 #4,试试用 @media print ?

    @media print {
    pre > code {
    white-space: pre-wrap;
    }
    }
    gouchaoer2
        7
    gouchaoer2  
    OP
       2020-08-24 11:50:55 +08:00
    @demo 3q,还是不想
    gouchaoer2
        8
    gouchaoer2  
    OP
       2020-08-24 11:51:10 +08:00
    @demo 3q,还是不行
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4033 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 05:10 · PVG 13:10 · LAX 22:10 · JFK 01:10
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.