html - 选择选项不格式化

标签 html css

我有一些代码可以使用 ul 和 li Here is the first jsfiddle 生成下拉列表.这就是我希望下拉菜单的外观。但是,当我尝试将它们转换为选择和选项下拉列表时,我收到以下格式,current jsfiddle .我所做的只是用选项替换第一个 fiddle 中的 li 。任何想法如何解决这个问题或为什么这样做?它似乎忽略了我替换的所有内容

当前 HTML

<select  class="wrapper-dropdown-3 dropdown" name="Process" data-val-required="Required" dataval="true">
        <option value="">--- Select One ---</option>
        <option value="Extrusion"><a href="#">Extrusion</a></option>
        <option value="Injection"><a href="#">Injection</a></option>
        <option value="Secondary"><a href="#">Secondary</a></option>
        <option value="Vinyl Dip Molding"><a href="#">Vinyl Dip Molding</a></option>
</select>

当前 CSS

.wrapper-dropdown-3 {
    /* Size and position */
    position: relative;
    width: 200px;
    margin: 0 auto;
    padding: 10px;
    /* Styles */
    background: #fff;
    border-radius: 7px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    box-shadow: 0 1px 1px rgba(50, 50, 50, 0.1);
    cursor: pointer;
    outline: none;
    /* Font settings */
    font-weight: bold;
    color: #0000FF;
}
.wrapper-dropdown-3:after {
    content:"";
    width: 0;
    height: 0;
    position: absolute;
    right: 15px;
    top: 50%;
    margin-top: -3px;
    border-width: 6px 6px 0 6px;
    border-style: solid;
    border-color: #8aa8bd transparent;
}
.wrapper-dropdown-3 .dropdown {
    /* Size & position */
    position: absolute;
    width: 100%;
    height:100%;
    top: 0;
    left: 0;
    right: 0;
    /* Styles */
    background: white;
    border-radius: inherit;
    border: 0px solid rgba(0, 0, 0, 0.17);
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
    font-weight: normal;
    list-style: none;
    /* Hiding */
    opacity: 1;
    /*Gets rid of the padding where the bullets would be*/
    padding-left:0;
    -moz-appearance: none;
    -webkit-appearance:none;
    text-indent: 0.01px;
    text-overflow:'';
}
.wrapper-dropdown-3 .dropdown option a {
    display: block;
    padding: 10px;
    text-decoration: none;
    color: #0000FF;
    border-bottom: 1px solid #e6e8ea;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 1);
    transition: all 0.3s ease-out;
}
.wrapper-dropdown-3 .dropdown option i {
    float: right;
    color: inherit;
}
.wrapper-dropdown-3 .dropdown option:first-of-type a {
    border-radius: 7px 7px 0 0;
}
.wrapper-dropdown-3 .dropdown option:last-of-type a {
    border-radius: 0 0 7px 7px;
    border: none;
}
/* Hover state */
 .wrapper-dropdown-3 .dropdown option:hover a {
    background: #f3f8f8;
}
.wrapper-dropdown-3 .dropdown:after {
    content:"";
    width: 0;
    height: 0;
    position: absolute;
    bottom: 100%;
    right: 15px;
    border-width: 0 6px 6px 6px;
    border-style: solid;
    border-color: #fff transparent;
}
.wrapper-dropdown-3 .dropdown:before {
    content:"";
    width: 0;
    height: 0;
    position: absolute;
    bottom: 100%;
    right: 13px;
    border-width: 0 8px 8px 8px;
    border-style: solid;
    border-color: rgba(0, 0, 0, 0.1) transparent;
}
.wrapper-dropdown-3.active .dropdown {
    opacity: 1;
    pointer-events: auto;
}

最佳答案

您已经指定了一个类名 = "wrapper-dropdown-3 drop down"但是您的 CSS 中没有为此类设置样式的部分。此外,在使用 CSS 设置样式时,您应该注意 HTML DOM 结构。例如在代码中:

    <ul class="ul">
        <li class="li"></li>
    </ul>

你会有这样的 CSS:

    .ul{/*CSS code*/}

.ul .li{/*CSS code*/}

不是

.li{/*CSS code*/}

因为 li 标签在 ui 标签内

关于html - 选择选项不格式化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22973513/

相关文章:

javascript - 文本框中的链接更改

javascript - 如何仅使用 javascript 调用此 url

php - 如何在不同的 div 中检索 php 中的值?

html - bg-info 不适用于 bootstrap 中的全身

php - 登录时显示数据库中的个人资料数据

css - 在 netlify css 上部署失败 ./node_modules/gatsby/node_modules/css-loader

css - 一定是我犯的一个简单错误 : Flex CSS style not working in a trival case

javascript - 下划线在鼠标悬停时展开

html - CSS 文本布局 HTML, CSS

html - 定义列表常见问题解答 - 避免在 <dd> 标记中将文本环绕在图标周围