样式选择选项以显示所有并显示为链接?

时间:2013-09-25 14:13:48

标签: css select styles hyperlink options

我以前尝试将样式下拉列表转换为标准的无序列表,而我能够这样做,但我需要在下拉列表中保留其值并在单击或选中时链接到这些值。

所以,我想知道是否可以设置选择下拉列表而不是转换它,以便它默认显示其中的所有选项,它们看起来好像是标准的href链接?

2 个答案:

答案 0 :(得分:1)

我不确定这是否是你想要的,但希望它有所帮助。 http://codepen.io/wallaceerick/pen/ctsCz

http://codepen.io/balduran/pen/CBEth

答案 1 :(得分:0)

选择风格很糟糕,特别是如果你关注旧浏览器。你不能只用CSS做任何事情,至多你可以做this kind of stuff

但是,你可以模仿你想要的行为......如果你愿意使用Javascript,例如你可以做这样的事情

<style>
.fake-link {
    color:#0044ff;
    text-decoration: underline;
    cursor:pointer;
}
</style>

<select onchange="location = this.options[this.selectedIndex].value;">
    <option value="#">Select a Link</option>
    <option class="fake-link" value="http://stackoverflow.com/">A fake link</option>
    <option class="fake-link" value="http://google.com">Another, another fake link</option>
</select>

令人讨厌的是你必须深入Javascript来做一些听起来很简单的事情,但据我所知,你不能以任何其他方式做到这一点

相关问题