在.net中从左到右设置链接按钮?

时间:2009-12-04 00:25:08

标签: .net asp.net css css3

<tr>
    <td align="right">
        <div style="background-image: url(image/menustript.bmp); border-right: #ffffff 2px outset; border-top: #ffffff 2px outset; border-left: #ffffff 2px outset; border-bottom: #ffffff 2px outset;">
            <asp:ImageButton ID="ibtn_home" runat="server"  ImageUrl="~/image/homebutton.jpg" ImageAlign="Middle" OnClick="ibtn_home_Click" Height="21px"/>
            <asp:ImageButton ID="ibtn_teacher"  runat="server"  ImageUrl="~/image/teacher.png" ImageAlign="Middle" width="90" OnClick="ibtn_teacher_Click"/>
            <asp:ImageButton ID="ibtn_student"  runat="server"   ImageUrl="~/image/student.bmp" ImageAlign="Middle" OnClick="ibtn_student_Click" Height="21px"/>
            <asp:ImageButton ID="ibtn_result" runat="server"  ImageUrl="~/image/result.JPG" ImageAlign="Middle" OnClick="ibtn_result_Click" Height="21px"/>
            <asp:ImageButton ID="ibtn_logoff" runat="server"  ImageUrl="~/image/logout.bmp" ImageAlign="Middle" OnClick="ibtn_logoff_Click" height="21px"/>
        </div>
    </td>
</tr>

想要设置如下

home | teacher | student | result |                                     logout

但是,当管理员登录时,所有菜单都应该如上所述..

但是当学生甚至在主页上。菜单应该如下,

home | student | result

当老师登录时,菜单应该如下,

home | student | result |                                               logout

任何人都可以帮我..用css或没有CSS设置菜单.. 但是给我一些像这样设置菜单的东西。

2 个答案:

答案 0 :(得分:2)

这不是很理想,但您需要在图片按钮中添加属性CssClass。

然后在定义的类上设置以下样式:

float: left; display: block; padding-left: 5px; padding-right: 5px;

答案 1 :(得分:2)

试试这个:

<style type="text/css">
    .menuRow
    {
        background-image: url(image/menustript.bmp); 
        border-right: #ffffff 2px outset;
        border-top: #ffffff 2px outset; 
        border-left: #ffffff 2px outset; 
        border-bottom: #ffffff 2px outset;
    }
    .leftItem
    {
        float: left; display: block; padding-left: 5px; padding-right: 5px;
    }
</style>
<table>
    <tr class="menuRow">
        <td align="left">
                <asp:imagebutton id="ibtn_home" runat="server" imageurl="~/image/homebutton.jpg"
                    imagealign="Middle" onclick="ibtn_home_Click" height="21px" class="leftItem" />
                <asp:imagebutton id="ibtn_teacher" runat="server" imageurl="~/image/teacher.png"
                    imagealign="Middle" width="90" onclick="ibtn_teacher_Click" class="leftItem"/>
                <asp:imagebutton id="ibtn_student" runat="server" imageurl="~/image/student.bmp"
                    imagealign="Middle" onclick="ibtn_student_Click" height="21px" class="leftItem"/>
                <asp:imagebutton id="ibtn_result" runat="server" imageurl="~/image/result.JPG" imagealign="Middle"
                    onclick="ibtn_result_Click" height="21px" class="leftItem"/>
        </td>
        <td align="right">
            <asp:imagebutton id="ibtn_logoff" runat="server" imageurl="~/image/logout.bmp" imagealign="Middle"
                    onclick="ibtn_logoff_Click" height="21px" />
        </td>
    </tr>
</table>