1

我有一个设置了固定宽度的 asp.net TreeView 控件,但是即使我在节点上指定了宽度,我的节点文本也会超出控件的边缘:

<style type="text/css">
    .treeNode {
        color:red;
        font: 14px Arial, Sans-Serif;
        width:30px;
    }

    .rootNode {
        font-size: 18px;
        color:blue;
        width:30px;
    }

    .leafNode {
        padding: 4px;
        color:orange;
        width:30px;
    }

    .selectNode {
        font-weight: bold;
        color:purple;
    }
</style>

<asp:TreeView ID="tvData" runat="server" ShowLines="True" Width="100" BorderStyle="Solid">
        <LeafNodeStyle CssClass="leafNode" />
        <NodeStyle CssClass="treeNode" />
        <RootNodeStyle CssClass="rootNode" />
        <SelectedNodeStyle CssClass="selectNode" />
        <Nodes>
            <asp:TreeNode Text="Root" Value="0">
                <asp:TreeNode Text="Products Products Products">
                    <asp:TreeNode Text="First Product" />
                    <asp:TreeNode Text="Second Product Second Product Second Product" />
                </asp:TreeNode>
            </asp:TreeNode>
        </Nodes>
    </asp:TreeView>

在此处输入图像描述

我想停止在控件边界之外运行的文本,但我不想将它换行到另一行。

4

1 回答 1

0

查看“mainTv”CSS

<style type="text/css">
          .treeNode
                {
                    color: red;
                    font: 14px Arial, Sans-Serif;
                    width: 30px;
                }

                .rootNode
                {
                    font-size: 18px;
                    color: blue;
                    width: 30px;
                }

                .leafNode
                {
                    padding: 4px;
                    color: orange;
                    width: 30px;
                }

                .selectNode
                {
                    font-weight: bold;
                    color: purple;
                }

                .mainTv
                {
                    display: table;
                }
            </style>

            <asp:TreeView ID="tvData" runat="server" CssClass="mainTv" ShowLines="True" Width="100px"
                BorderStyle="Solid">
                <LeafNodeStyle CssClass="leafNode" />
                <NodeStyle CssClass="treeNode" />
                <RootNodeStyle CssClass="rootNode" />
                <SelectedNodeStyle CssClass="selectNode" />
                <Nodes>
                    <asp:TreeNode Text="Root" Value="0">
                        <asp:TreeNode Text="Products Products Products">
                            <asp:TreeNode Text="First Product" />
                            <asp:TreeNode Text="Second Product Second Product Second Product" />
                        </asp:TreeNode>
                    </asp:TreeNode>
                </Nodes>
            </asp:TreeView>

在此处输入图像描述

.mainTv
        {
            overflow:hidden;
        }

在此处输入图像描述

于 2013-09-05T08:57:37.163 回答