• 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 

  • 相关阅读:
    Solution -「CF 1025G」Company Acquisitions
    Solution -「Code+#4」「洛谷 P4370」组合数问题 2
    YApi,顶尖API接口管理平台
    Hibernate (开放源代码的对象关系映射框架)
    【LeetCode】5. 最长回文子串
    【LeetCode】105. 从前序与中序遍历序列构造二叉树
    【LeetCode】76. 最小覆盖子串
    【LeetCode】974. 和可被 K 整除的子数组
    【LeetCode】394. 字符串解码
    【LeetCode】5424. 数组中两元素的最大乘积
  • 原文地址:https://www.cnblogs.com/cxxjohnson/p/5080826.html
Copyright © 2020-2023  润新知