V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
gouchaoer2
V2EX  ›  CSS

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

  •  
  •   gouchaoer2 · Aug 24, 2020 · 2407 views
    This topic created in 2082 days ago, the information mentioned may be changed or developed.

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

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

    8 replies    2020-08-24 11:51:10 +08:00
    demo
        1
    demo  
       Aug 24, 2020
    pre > code {
    white-space: pre-wrap;
    }
    misaka19000
        2
    misaka19000  
       Aug 24, 2020
    white-space: initial;
    sixway
        3
    sixway  
       Aug 24, 2020
    一楼的可行。
    gouchaoer2
        4
    gouchaoer2  
    OP
       Aug 24, 2020
    @demo 好的,3q 我搞定了

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

    @media print {
    pre > code {
    white-space: pre-wrap;
    }
    }
    gouchaoer2
        7
    gouchaoer2  
    OP
       Aug 24, 2020
    @demo 3q,还是不想
    gouchaoer2
        8
    gouchaoer2  
    OP
       Aug 24, 2020
    @demo 3q,还是不行
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4077 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 45ms · UTC 10:21 · PVG 18:21 · LAX 03:21 · JFK 06:21
    ♥ Do have faith in what you're doing.