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

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

  •  
  •   junan · Jan 29, 2023 · 1558 views
    This topic created in 1186 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   ·   1016 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 22:09 · PVG 06:09 · LAX 15:09 · JFK 18:09
    ♥ Do have faith in what you're doing.