V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
junan
V2EX  ›  前端开发

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

  •  
  •   junan · 2023-01-29 15:17:29 +08:00 · 954 次点击
    这是一个创建于 425 天前的主题,其中的信息可能已经有所发展或是发生改变。

    比如 dom

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

    转成 css

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

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

    你需要自己转一下 json, 才能变成 css 格式。
    bojue
        3
    bojue  
       2023-02-02 11:24:27 +08:00
    不灵活,还不然定义公共样式类,命令行生成代码块
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2856 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 13:13 · PVG 21:13 · LAX 06:13 · JFK 09:13
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.