zoukankan      html  css  js  c++  java
  • css+js实现兼容性select的样式

    <!doctype html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <meta name="Generator" content="EditPlus®">
    <meta name="Author" content="">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    <title>Document</title>
    <script type= text/javascript >
    var $$ = function (id) {
    return document.getElementById(id);
    }
    window.onload = function () {
    var btnSelect = $$("btn_select");
    var curSelect = btnSelect.getElementsByTagName("span")[0];
    var oSelect = btnSelect.getElementsByTagName("select")[0];
    var aOption = btnSelect.getElementsByTagName("option");
    oSelect.onchange = function () {
    var text=oSelect.options[oSelect.selectedIndex].text;
    curSelect.innerHTML = text;
    }
    }
    </script>
    <style type= text/css >
    *{
    margin: 0;
    padding: 0;
    }
    body {
    padding: 50px 50px;
    }
    .btn-select {
    position: relative;
    display: inline-block;
    150px;
    height: 25px;
    font: 14px/20px "Microsoft YaHei";
    }
    .btn-select .cur-select {
    position: absolute;
    display: block;
    150px;
    height: 25px;
    line-height: 25px;
    background: url(ico-arrow.png) no-repeat 125px center;
    text-indent: 10px;
    border:solid #999 1px;
    }
    .btn-select:hover .cur-select {
    /*background-color: #f90;*/
    }
    .btn-select select {
    position: absolute;
    top: 0;
    left: 0;
    150px;
    height: 25px;
    opacity: 0;
    filter: alpha(opacity: 0;);
    font: 14px/20px "Microsoft YaHei";
    }
    .btn-select select option {
    text-indent: 30px;
    }
    .btn-select select option:hover {
    /*background-color: #f80;
    color: #fff; */
    }

    .styled-select select {
    150px;
    padding-left: 5px;
    font-size: 12px;
    border: 1px solid #ccc;
    height: 25px;
    -webkit-appearance: none; /*for chrome*/
    background: url(ico-arrow.png) no-repeat right center ;
    }
    </style>
    </head>
    <body>
    <form>
    <a class="btn-select" id="btn_select">
    <span class="cur-select">请选择</span>
    <select>
    <option>选项一</option>
    <option>选项二</option>
    <option>选项三</option>
    <option>选项四</option>
    <option>选项五</option>
    </select>
    </a>
    </form>

    <select>
    <option>选项一</option>
    <option>选项二</option>
    <option>选项三</option>
    <option>选项四</option>
    <option>选项五</option>
    </select>


    <div class="styled-select">
    <select>
    <option>Here is the first option</option>
    <option>The second option</option>
    </select>
    </div>
    </body>
    </html>

    select{ 
    margin: 0; 
    padding: 0; 
    outline: none; 
    height: 25px; 
    line-height: 25px; 
    120px; 
    border: rgb(191, 204, 220) 1px solid; 
    border-radius: 3px; 
    display: inline-block; 
    font: normal 12px/25px "微软雅黑", "SimSun", "宋体", "Arial"; 
    background-size: 5px 5px,5px 5px,25px 25px,1px 25px; 
     
    background-image: repeating-linear-gradient(225deg,rgb(105,123,149) 0%,rgb(105,123,149) 50%,transparent 50%,transparent 100%), 
    repeating-linear-gradient(135deg,rgb(105,123,149) 0%,rgb(105,123,149) 50%,transparent 50%,transparent 100%), 
    linear-gradient( #FFFFFF 0%,#F8F9Fd, #EFFAFA 100%), 
    repeating-linear-gradient( rgb(191, 204, 220) 0%,rgb(191, 204, 220) 100%); 
    background-repeat: no-repeat; 
    background-position: 101px 10px,106px 10px,right top,92px top; 
    -webkit-appearance: none 

  • 相关阅读:
    offsetLeft 和 style.left
    wampserver 使用小结,操作一:wamp 配置虚拟域名 操作二:wamp 127.0.0.1正常打开,localhost空白403/404
    多栏目显示隐藏
    javascript闭包,for循环同步和异步
    wordpress 主题模板常用内容调用代码
    ECMAScript 6 let和var区别和应用
    js jquery获取所有同级相邻元素,同tag标签,中间有间隔其他tag的不算,不是siblings
    微信小程序如何使用百度API实现身份证查询
    微信小程序视频弹幕效果
    不得不知的小程序基本知识
  • 原文地址:https://www.cnblogs.com/cxxjohnson/p/5080826.html
Copyright © 2011-2022 走看看