【问题标题】:set style for above IE8 only只为以上 IE8 设置样式
【发布时间】:2016-01-01 23:36:14
【问题描述】:

我有一个 ASP.NET 文件上传控件。为文件上传控件的“浏览”按钮提供自定义样式我正在编写以下代码:

label.choose:before {
        background: #f07222 none repeat scroll 0 0;
        border: 0 none;
        border-radius: 5px;
        color: #fff;
        cursor: pointer;
        font-weight: bold;
        padding: 4.5px 12px;           
        text-transform: uppercase;
        content: 'Browse';
        position: absolute;
        -webkit-margin-before: -2px;
        -webkit-padding-start: 19px;
        -webkit-padding-end: 19px;
    }

 <label class="choose">
      <asp:FileUpload ID="FileUpload_DataFile" runat="server" />
 </label>

它在 FireFox 和 Chrome 中工作正常。但在 IE 浏览按钮显示输入文本的右侧。在 FF 和 Chrome 中它显示在左侧。所以我的代码在 IE 中不起作用。 如果我添加

margin-left:141px;

仅适用于 IE,但如何仅为 IE 浏览器添加此属性? 我有 IE11。我想为以上 IE8 执行此操作。当我对此进行研发时,我发现了 IE 的条件样式,但它不适用于 IE9 以上。

是否可以仅应用自定义样式文件上传按钮?如果可以,请给我代码示例?

任何只为 IE 添加样式的解决方案? 或者有其他方法可以做到这一点?

【问题讨论】:

标签: javascript html css asp.net internet-explorer


【解决方案1】:

我的问题得到了答案!!!

只为IE设置css样式编写以下代码。

_:-ms-input-placeholder, :root .choose:before {                
            margin-left: 141px;               
        }

这在 IE11 上运行良好..!!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-05-26
    • 1970-01-01
    • 1970-01-01
    • 2011-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多