在Internet Explorer中为HTML SELECT设置样式 [英] Styling HTML SELECT in Internet Explorer

查看:176
本文介绍了在Internet Explorer中为HTML SELECT设置样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在IE中任何方式自定义HTML SELECT 的边框和背景?我可以在Firefox中用简单的CSS样式化边框,但是在IE中不能使用。

Any way to customize the border and background of an HTML SELECT in IE? I can style the border with simple CSS in Firefox, but apparantly not in IE.

推荐答案

IE很可能在怪异模式。以前的IE版本没有画出 select 元素本身,因此它不能被正确地样式化(以及一些z-次序怪癖),所以在IE< 8你根本不能做,除非你在JS中重新实现 select 。看看开发者工具(F12),看看IE是在哪个浏览器和文档模式;如果浏览器模式显示为Internet Explorer 8,文档模式显示为Quirks mode,则应该确定:)

IE is most likely in quirks mode. Previous versions of IE didn't draw the select element themselves and thus it couldn't be styled properly (as well as some z-order quirks), so on IE < 8 you simply can't do it, unless you re-implement something like select in JS. Take a look at the developer tools (F12) to see which browser and document mode IE is in; if it says "Internet Explorer 8" for the Browser mode and not "Quirks mode" for the document mode, you should be ok :)

以下代码段在此处正常工作(IE8β2):

The following snippet works fine here (IE8β2):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
            "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <style type="text/css">
            select {
                border: 1px solid red;
            }
        </style>
    </head>
    <body>
        <form>
            <select>
                <option>1</option>
                <option>2</option>
            </select>
        </form>
    </body>
</html>

这篇关于在Internet Explorer中为HTML SELECT设置样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆