html - 如何模仿html选择框

标签 html css html-select

我想要一个普通的 html 选择,而不是文本有 css/图像。现在我知道这不能在除 Firefox 之外的任何浏览器中完成,但我想知道是否有办法使用 JavaScript 来解决这个问题。我的网站必须在功能手机(即非智能手机)上显示,而 JavaScript 在这些手机上不起作用。有什么办法解决这个问题吗?

最佳答案

经过数小时的工作,我找到了一个合理的解决方案。如果您希望“图像”出现在您的 html 中,请选择简单地使用 font-face。因此,请在线下载字母表中带有星号的字体。然后在css中使用以下内容。确保你的 url 路径是正确的:

font-family: 'WebSymbolsRegular';
        src: url('../css/websymbols-regular-webfont.eot');
        src: url('../css/websymbols-regular-webfont.eot?#iefix') format('embedded-opentype'),
             url('../css/websymbols-regular-webfont.woff') format('woff'),
             url('../css/websymbols-regular-webfont.ttf') format('truetype'),
             url('../css/websymbols-regular-webfont.svg#WebSymbolsRegular') format('svg');
        }

    #Condition
    {
        font-family: 'WebSymbolsRegular';
    }

然后在您的 html 中选择具有以下内容:

<select id = "Condition">
      <option >R</option>
      <option >RR</option>
      <option >RRR</option>
      <option >RRRR</option>
      <option >RRRRR</option>
</select>

我们使用 R 是因为 R 是代表该给定字体中的星号的字母。另请查看以下 link .真的很有帮助

关于html - 如何模仿html选择框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14439074/

相关文章:

html - 百分比表盘颜色重叠问题

javascript - 抵消现有风格

PHP 更新在编辑表单中的下拉列表中选择的内容

html选择标签问题

javascript - 如何创建一个 "show more"按钮并指定最初可以显示多少行文本

jquery - 浏览器中的自定义进度条

javascript - 将数据添加到确认对话框

html - 媒体查询 <body> div 有效,但其他无效

jquery-select2 - 在 Select2 事件中获取选中的选项,当可以选择多个选项时

javascript - Ajax Loader Gif 在 IE 或 Chrome 中不工作