1

我有一个 DIV 内的文本框和一个 div 外的按钮。我需要(文本框和按钮)都在同一行。在 Internet Explorer 中,两者都在同一行。但是,在 Mozilla 中,按钮位于下一行。附上截图。

图片: 在 Mozilla 中查看 在 IE 中查看

aspx/HTML 代码:

<div class="fileInputs">
<asp:FileUpload class="hiddenFile" ID="fucAttachment" runat="server" onmouseout="copyContents('fucAttachment');" />
<div class="visibleField">
    <input type="text" readonly="readonly" id="visibleAttachmentField" style="width: 158px; height: 18px; margin-left: -4px;" />
</div>
<input type="button" class="browseBtn" value="Browse"/>

CSS:

 div.fileInputs
    {
        position: relative;
        z-index: 0;
    }
    .hiddenFile
    {
        position: relative;
        text-align: right;
        -moz-opacity: 0;
        filter: alpha(opacity: 0);
        opacity: 0;
        z-index: 2;
        width: 220px;
        /*cursor: pointer; cursor: hand; */
    }
    .visibleField
    {
        position: absolute;
        top: 0px;
        left: 0px;
        z-index: 1;
        margin-left: 4px;
        display: inline-block;            
    }
    .browseBtn, .uploadBtn
    {
        cursor: pointer;
        float: RIGHT;
        position: ABSOLUTE;
        margin-left: -60PX;
        height: 20px;
        font-size:12px;
        font-family: Arial;
        padding-left: 6px; 
        padding-right: 6px;
        border:1px solid #768ea5; 
        background-image: none;
        background-color: rgb(214,211,206);
    }
4

1 回答 1

0

为什么不把按钮放在 div 里面。

将两个输入都向左浮动。如果您的容器 div 将被定位为绝对,您还需要为容器 div 提供宽度。

如果您需要不可见文本/输入,则只针对该 div 而不是整个 div。

于 2013-11-04T11:33:32.067 回答