select/redio 样式美化(select兼容ie9)

select:


 css:

.search-input {

    border: 1px solid #cdcdcd;

    width: 180px;

    text-indent: 0.6em;

}

.sel_mask {

    position: relative;

    height: 30px;

    display: inline-block;

    text-decoration: none;

    border: 1px solid #cdcdcd;

    vertical-align: middle;

}

.sel_mask span {

    position: absolute;

    top: 0px;

    left: 5px;

    right: 20px;

    height: 30px;

    line-height: 30px;

    display: inline-block;

    color: #333;

    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;

}

.sel_mask i {

    display: inline-block;

    position: absolute;

    top: -1px;

    right: -1px;

}

.select-bgc {

    display: inline-block;

    width: 27px;

    height: 30px;

    background: url(../img/arrow-down.png);         /*替换默认箭头图片*/

}

.sel_mask select {

    top: 0px;

    left: 0px;

    position: absolute;

    height: 30px;

    opacity: 0;

}

.search-input {

    border: 1px solid #cdcdcd;

    width: 180px;

    text-indent: 0.6em;

}

js:

// select文件名获取(一页多个seclect)

$('.register-select').each(function (i,item) {

    if($(item).find('option:selected').html() === '' || $(item).find('option:selected').html() === '请选择') {

        $(item).siblings('span').html('请选择');

    } else {

        $(item).siblings('span').html($(item).find('option:selected').html());

};

    $(item).change(function () {    // 选择后替换内容并恢复箭头方向

        $(item).siblings('span').html($(item).find('option:selected').html());

})

})

redio:



css:

.input-file {

    opacity: 0;

    height: 30px;

    position: absolute;

}

.radio-icon {

    display: inline-block;

    width: 13px;

    height: 14px;

    background: url(../img/input-radio.png) no-repeat 0 0;       /*替换默认选中点图片*/

    vertical-align: middle;

}

.radio-icon-none {

    display: inline-block;

    width: 13px;

    height: 14px;

    background: url(../img/input-radio.png) no-repeat -13px 0px;      /*替换默认未选中点图片*/

    vertical-align: middle;

}

js:

// radio单选切换选中状态样式

function redioChecked(thisRedio) {

    if (thisRedio.checked == true) {

        var name = $(thisRedio).prop("name");

        $('input.input-file[type=radio][name=' + name + ']').next('i').removeClass('radio-icon').addClass('radio-icon-none');

        $(thisRedio).next('i').removeClass('radio-icon-none').addClass('radio-icon');

}

};

$('input.input-file[type=radio]').each(function (i,item) {

    var thisRedio = this;

    redioChecked(thisRedio);

})

$('input.input-file[type=radio]').change(function () {

    var thisRedio = this;

    redioChecked(thisRedio);

});

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 问答题47 /72 常见浏览器兼容性问题与解决方案? 参考答案 (1)浏览器兼容问题一:不同浏览器的标签默认的外补...
    _Yfling阅读 14,179评论 1 92
  • 第一部分 HTML&CSS整理答案 1. 什么是HTML5? 答:HTML5是最新的HTML标准。 注意:讲述HT...
    kismetajun阅读 28,847评论 1 45
  • 1. tab列表折叠效果 html: 能源系统事业部 岗位名称: 工作地点 岗位名...
    lilyping阅读 2,015评论 0 1
  • 深入理解傅里叶变换Mar 12, 2017 这原本是我在知乎上对傅立叶变换、拉普拉斯变换、Z变换的联系?为什么要进...
    价值趋势技术派阅读 5,943评论 2 2
  • 异常处理概述 python程序在执行的时候,经常会遇到异常,如果中间异常不处理,经常会导致程序崩溃。比如爬虫,如果...
    techLee阅读 171评论 0 0

友情链接更多精彩内容