junan

有没有工具可以把 Dom 结构转 CSS 结构

  •  
  •   junan · Jan 29, 2023 · 1620 views
    This topic created in 1214 days ago, the information mentioned may be changed or developed.

    比如 dom

    <div class="box">
      <div class="title">
        <img />
      </div>
      <span></span>
    </div>
    

    转成 css

    .box {
      .title {
        img {
    
        }
      }
        
      span {
        
      }
    }
    
    3 replies    2023-02-02 11:24:27 +08:00
    Rache1
        1
    Rache1  
       Jan 29, 2023
    这种死板的话,解析成 AST 遍历一遍就有了吧。
    3dwelcome
        2
    3dwelcome  
       Jan 29, 2023
    https://astexplorer.net/

    源代码选 html, 会生成 json 格式。

    你需要自己转一下 json, 才能变成 css 格式。
    bojue
        3
    bojue  
       Feb 2, 2023
    不灵活,还不然定义公共样式类,命令行生成代码块
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3162 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 12:51 · PVG 20:51 · LAX 05:51 · JFK 08:51
    ♥ Do have faith in what you're doing.