[英]Is it possible to style a html select drop-down like this and still keep it mobile friendly?
First, this is what the drop-down should look like: 首先,下拉菜单如下所示:
This should be just a normal html select
这应该只是一个普通的html
select
<select>
<option>January</option>
<option>February</option>
<option>March</option>
...
</select>
There's probably some JQuery component library out there that I can use, but what I also want is that when you're on mobile, eg Android, iOS, etc... that the mobile browser will handle the display/ineraction of the select box, rather than having the user interact with the drop-down as it is displayed in the screenshot... In other words, this styling should only apply for desktop. 我可能有一些可以使用的JQuery组件库,但是我还想要的是当您使用移动设备(例如Android,iOS等)时,移动浏览器将处理选择框的显示/不显示,而不是让用户与屏幕快照中显示的下拉菜单进行交互……换句话说,此样式应仅适用于桌面。
So you want one element to be displayed on desktop, and a different one displayed on mobile, why not have them both in the markup and display a different one via CSS depending on the size of the screen? 因此,您希望一个元素显示在桌面上,而另一个元素显示在移动设备上,为什么不将它们同时包含在标记中并根据屏幕大小通过CSS显示另一个元素呢?
@media screen and (max-width: 760px){
#select-box{
display:inherit;
}
#dropdown-box{
display:none;
}
}
@media screen and (min-width: 761px){
#select-box{
display:none;
}
#dropdown-box{
display:inherit;
}
}
Something like that? 这样的东西? note that display:inherit should be whatever display the element is having by default.
请注意,display:inherit应该是元素默认具有的任何显示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.