You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在类HTML标签中实现多行左对齐?前两行生效第三行失效求助

Fixing Multi-Line Left Alignment in Graphviz Node Labels

Got it, let's fix that left-alignment issue in your Graphviz node label! The problem here is that Graphviz defaults to centering content in HTML-formatted labels, and your <BR ALIGN="LEFT"/> only affects the line immediately after the break—your final line doesn't get that alignment hint, so it falls back to the default center.

The reliable way to make all lines left-aligned is to wrap your entire label content in a <div align="left"> container. This ensures every line inside inherits the left-alignment rule. Here's your adjusted code:

digraph TTS { 
    node [shape="box"]; 
    a [label=<
        <div align="left">
            line 1 --------<BR/>
            line 2 ----<BR/>
            line 3
        </div>
    >]; 
}

A quick note: Graphviz uses a simplified subset of HTML, and the ALIGN attribute on <BR> isn't fully supported or reliable. Using a container-level alignment (like the <div> here) is a much more consistent approach. With this change, all three lines will stay left-aligned as you expect!

内容的提问来源于stack exchange,提问作者gauss256

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 07:07:38