jquery - HTML 选择标签呈现问题

标签 jquery html css internet-explorer windows-mobile

目前,我在 html select 标签中遇到渲染问题。我有几个 select 标签,其中一个 select 标签的选项是静态的,而另一个 select 标签的选项是动态的,它使用 jQuery 填充

我在 Motorola ES400 设备上使用 internet explorer 6 mobile 浏览器。

当我的网页加载到屏幕上时,它显示如下:

这里我的第一个选择标签是静态的,另外三个选择标签的选项标签是使用 jQuery 生成的。

个人感觉可能是重渲染的问题。

如果我滚动它显示正常的网页:

我正在为选择标签使用以下 CSS:

    width               : 240px;
    height              : 24px;
    border              : 1px solid #cccccc;
    vertical-align      : middle;

Please click here for the JSFiddle

最佳答案

尝试使用 :after 和 :before 来实现这个技巧

body, html {background:#444; text-align:center; padding:50px 0;}

/* The CSS */
select {
    padding:3px;
    margin: 0;
    -webkit-border-radius:4px;
    -moz-border-radius:4px;
    border-radius:4px;
    -webkit-box-shadow: 0 3px 0 #ccc, 0 -1px #fff inset;
    -moz-box-shadow: 0 3px 0 #ccc, 0 -1px #fff inset;
    box-shadow: 0 3px 0 #ccc, 0 -1px #fff inset;
    background: #f8f8f8;
    color:#888;
    border:none;
    outline:none;
    display: inline-block;
    -webkit-appearance:none;
    -moz-appearance:none;
    appearance:none;
    cursor:pointer;
}

/* Targetting Webkit browsers only. FF will show the dropdown arrow with so much padding. */
@media screen and (-webkit-min-device-pixel-ratio:0) {
    select {padding-right:18px}
}

label {position:relative}
label:after {
    content:'<>';
    font:11px "Consolas", monospace;
    color:#aaa;
    -webkit-transform:rotate(90deg);
    -moz-transform:rotate(90deg);
    -ms-transform:rotate(90deg);
    transform:rotate(90deg);
    right:8px; top:2px;
    padding:0 0 2px;
    border-bottom:1px solid #ddd;
    position:absolute;
    pointer-events:none;
}
label:before {
    content:'';
    right:6px; top:0px;
    width:20px; height:20px;
    background:#f8f8f8;
    position:absolute;
    pointer-events:none;
    display:block;
}
<label>
    <select>
        <option selected> Select Box </option>
        <option>Short Option</option>
        <option>This Is A Longer Option</option>
    </select>
</label>

关于jquery - HTML 选择标签呈现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38821896/

相关文章:

javascript - 像分析一样的跟踪脚本

javascript - 实现模态工厂?

javascript - 我需要在同一页面上同时使用 "log in with Google"和 "sign up with Google"按钮

javascript - Codepen Carousel 无法正常显示或运行?

html - 当另一个元素改变大小时如何避免html页面中的元素移动

javascript - JS Canvas - 保存透明图像

html - 网站 iPad 显示呈现问题

javascript - 如何为 jQuery 中的每个数组元素附加不同的动画效果?并使用 2 个按钮(下一个)一个一个地向前和向后设置动画?

javascript - jQuery 克隆的 div 不响应点击事件

html - Safari 第 n 个子错误