asp.net – 我很难很好地定位这个按钮
我现在已经开始使用1.5小时了,我无法想出办法让它成为我想要的方式.我对网络上的所有东西都很陌生,并且需要花费大量时间(可能更多?)来尝试将事物放在我想要的地方并以优雅的方式进行.
无论如何,我有两个文本框,上面有两个标签,并在框上方居中.我想简单地在它们之间放一个按钮,并以文本框的高度为中心. 这就像我能够达到我想要的那样接近.我希望左侧文本框移动,以便它与“跳转到:”,“客户:”,“和”客户#:“排成一行,然后右侧的框与右侧的相同距离可能是”下一步“按钮只有10px高,但仍然居中.这张照片的问题是它只在显示和展开文本框时才有效,如果它们被隐藏,那么面板实际上会在Customer#部分上方呈现,因为如何我操纵了我猜的边距. http://img192.imageshack.us/img192/259/controls.jpg http://img192.imageshack.us/img192/259/controls.jpg 这是我与< div> s的尝试 <div style="position:relative; overflow:auto; margin-top:15px; margin-bottom:10px;"> <div style="width:40%; float:left; margin-left:10px;"> <div><asp:Label runat="server" ID="lblInfoDesc" /></div> <div><asp:TextBox ID="txtInfoDescription" runat="server" TextMode="MultiLine" Rows="3" MaxLength="500" Width="100%" /></div> </div> <%--<div style="position:absolute; margin-top:25px; margin-left:-10px;"><asp:Button ID="Button1" runat="server" Text="Next" /></div>--%> <div style="width:40%; float:right; margin-right:16px;"> <div><asp:Label runat="server" ID="lblInfoData" /></div> <div><asp:TextBox ID="txtInfoData" runat="server" TextMode="MultiLine" Rows="3" MaxLength="500" Width="100%" /></div> </div> </div> 这是我对表元素的尝试 <div style="margin-bottom:10px;"> <table style="position:relative; width:100%; margin-bottom:15px;"> <tr style="text-align:center";> <td><asp:Label runat="server" ID="lblInfoDesc" /></td> <td></td><td></td><td></td><td></td> <td><asp:Label runat="server" ID="lblInfoData" /></td> </tr> <tr> <td style="margin-left: 0px;"><asp:TextBox ID="txtInfoDescription" runat="server" TextMode="MultiLine" Rows="3" MaxLength="500" Width="80%" /></td> <td></td><td></td><td></td><td></td> <td style="margin-right:10px;"><asp:TextBox ID="txtInfoData" runat="server" TextMode="MultiLine" Rows="3" MaxLength="500" Width="80%" /></td> </tr> </table> <div style="position:inherit; text-align:center; margin-top:-55px; margin-bottom:25px;"> <asp:Button ID="Button2" runat="server" Text="Next" /> </div> </div> 所有这些< td>< / td>< td>< / td>< td>试图在按钮和文本框之间放置空格,因为我无法获得浮动或边距.任何帮助将非常感激! 这是完整的页面来源: <asp:Panel ID="pnlCustomer" runat="server" style="background-color:#ccccff; width:500px; height:90%; position:relative;" BorderColor="DarkBlue" BorderWidth="2px"> <div style="position:relative; margin-top:10px; margin-left:10px;"> <div style="color:#003399; font-size:18px; text-align:left;">Jump To: <asp:DropDownList ID="ddlCategory" runat="server" AutoPostBack="True" onselectedindexchanged="ddlCategory_SelectedIndexChanged" style="margin-left:40px;"/> </div> </div> <div style="position:relative; margin-top:10px; margin-left:10px;"> <div style="color:#003399; font-size:18px; text-align:left;">Customer: <asp:DropDownList ID="ddlCustomersList" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlCustomersList_SelectedIndexChanged" style="margin-left:35px;"/> <asp:Button ID="btnAddCustomer" runat="server" Text="Add" OnClick="btnAddCustomer_Click" OnClientClick="return confirm('Warning: This will redirect you from the page');" /> </div> </div> <div style="position:relative; margin-top:10px; margin-left:10px;"> <div style="color:#003399; font-size:18px; text-align:left;">Customer #: <asp:DropDownList ID="ddlCustomerNumber" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlCustomerNumber_SelectedIndexChanged" style="margin-left:20px;"/> <asp:TextBox ID="txtCustomerNumber" runat="server" style="margin-left:20px;" /> <asp:Button ID="btnModify" runat="server" Text="Modify" OnClick="btnModify_Click" /> <asp:Button ID="btnCreateNew" runat="server" Text="Create New" OnClick="btnCreateNew_Click" /> <asp:Button ID="btnUpdate" runat="server" Text="Update" OnClick="btnUpdate_Click" /> <asp:Button ID="btnDelete" runat="server" Text="Delete" OnClick="btnDelete_Click" OnClientClick="return confirm('Do you want to delete the record ?');" /> <asp:Button ID="btnSaveNew" runat="server" Text="Save" OnClick="btnSaveNew_Click" /> <asp:Button ID="btnCancel" runat="server" Text="Cancel" OnClick="btnCancel_Click" /> </div> </div> <%-- <div style="margin-bottom:10px;"> <table style="position:relative; width:100%; margin-bottom:15px;"> <tr style="text-align:center";> <td><asp:Label runat="server" ID="lblInfoDesc" /></td> <td></td><td></td><td></td><td></td> <td><asp:Label runat="server" ID="lblInfoData" /></td> </tr> <tr> <td style="margin-left: 0px;"><asp:TextBox ID="txtInfoDescription" runat="server" TextMode="MultiLine" Rows="3" MaxLength="500" Width="80%" /></td> <td></td><td></td><td></td><td></td> <td style="margin-right:10px;"><asp:TextBox ID="txtInfoData" runat="server" TextMode="MultiLine" Rows="3" MaxLength="500" Width="80%" /></td> </tr> </table> <div style="position:inherit; text-align:center; margin-top:-55px; margin-bottom:25px;"> <asp:Button ID="Button2" runat="server" Text="Next" /> </div> </div>--%> <div style="position:relative; overflow:auto; margin-top:15px; margin-bottom:10px;"> <div style="text-align:center; margin-bottom:-20px; "> <asp:Button ID="btnNextInfo" runat="server" Text="Next" /> </div> <div style="width:40%; float:left; margin-left:10px;"> <div><asp:Label runat="server" ID="lblInfoDesc" /></div> <div><asp:TextBox ID="txtInfoDescription" runat="server" TextMode="MultiLine" Rows="3" MaxLength="500" Width="100%" /></div> </div> <div style="width:40%; float:right; margin-right:16px;"> <div><asp:Label runat="server" ID="lblInfoData" /></div> <div><asp:TextBox ID="txtInfoData" runat="server" TextMode="MultiLine" Rows="3" MaxLength="500" Width="100%" /></div> </div> </div> <div style="margin-top:-20px; position:absolute; font-size:12px;"><asp:Label runat="server" ID="lblErrorMessage" /></div> </asp:Panel> 解决方法
看起来这更像是一个CSS和HTML问题而不是ASP.Net问题.
要清楚,使用CSS在父级中垂直居中并不容易,诀窍是: >父元素必须具有位置:relative或absolute. 试试这个: <style> div.textboxArea { text-align:center; float:left; width:40%; height:400px; } .textboxArea textarea { width:80%; height:400px; } .centerMeVertically div { position:absolute; top:50%; vertical-align:middle; height:30px; width:100%; margin-top:-15px; text-align:center; } div.centerMeVertically { float:left; width:20%; text-align:center; height:400px; position:relative; } p { height:35px; margin:-35px 0 0 0; } .container { margin-top:35px; } </style> <div class="container"> <div style="width:100%;"> <div class="textboxArea"> <p>Label 1</p> <textarea></textarea> </div> <div class="centerMeVertically"> <div><button>Button2</button></div> </div> <div class="textboxArea"> <p>Label 2</p> <textarea></textarea> </div> </div> </div> 编辑:看过你修改过的问题后,我修改了我的答案,只将按钮居中放在textarea的垂直位置. 你必须用顶级边缘做一些愚蠢的CSS技巧,但它完成了工作.还要注意容器div.这是为了确保如果您在标记中“放置”此代码段之上的任何内容,它就不会被标签重叠. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- 在VS环境下使用SVN
- asp.net – 如何将数据保存在MVC控制器的内存中?
- 如何识别ASP.NET Web表单和ASP.NET MVC网站?
- asp.net – ADO.NET在.NET内核可能吗?
- asp.net-mvc – 如何使用AJAX调用更新MVC中带有Add和Delete
- asp.net-mvc-3 – asp.net mvc3返回原始html来查看
- ASP.NET 5中是否有缓存模式的指导
- asp.net-mvc – 设置登台和生产环境,最大限度地减少简单托管
- 最好的TinyMce编辑器图像管理器/文件上传为Asp.net Mvc
- asp.net-mvc – 将.html文件渲染为ASP.NET MVC中的视图
- 解决:目录不存在。<br>参数名: directoryVirtua
- asp.net-mvc – asp.mvc中渲染的区别是什么
- Serilog接收ASPNET核心记录
- asp.net-mvc – MVC3验证与实体框架模型/数据库首
- asp.net-core – 使用AspNet Core 2.0进行Google
- asp.net-mvc-3 – 数据注释MVC3必需属性
- 文件上传 – 是否可以在上传文件的asp.net webap
- asp.net-mvc – ASP.NET MVC:使用EditorFor()和
- asp.net – 如何以编程方式将位置元素添加到Web配
- 在Kendo-UI图表中刷新方法和重绘方法有什么不同?