如何在选择输入中样式选项
我正在寻找选择
输入中的选项,并添加一些填充以增强外观。以下是我当前的CSS和HTML设置,但是我在将填充物应用于选项上很难。我可以进行什么调整来实现这一目标?
CSS:
label {
font-size: 15px;
font-family: 'Arial';
display: inline;
}
select {
display: inline;
padding: 5px 10px;
}
option {
/* How can I add padding to the options? */
}
HTML:
<label for="fruits">Fruits</label>
<select name="fruits">
<option>Apple</option>
<option>Mango</option>
<option>Banana</option>
<option>MuskMelon</option>
</select>
我感谢有关如何实现选项
元素的所需填充的任何指导或建议。谢谢你!
I'm looking to style the options within a select
input and add some padding to enhance the appearance. Below is my current CSS and HTML setup, but I'm having trouble applying the padding to the options. What adjustments can I make to achieve this?
CSS:
label {
font-size: 15px;
font-family: 'Arial';
display: inline;
}
select {
display: inline;
padding: 5px 10px;
}
option {
/* How can I add padding to the options? */
}
HTML:
<label for="fruits">Fruits</label>
<select name="fruits">
<option>Apple</option>
<option>Mango</option>
<option>Banana</option>
<option>MuskMelon</option>
</select>
I'd appreciate any guidance or suggestions on how to achieve the desired padding for the option
elements. Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能在类似的选项菜单内更改太多。如果您想制作完整的自定义下拉菜单,则必须自己制作所有组件。我很确定您只能在选项元素中更改文本,而不是周围环境中的文本,如果可以,则可能必须使用JavaScript而不是CSS
You can't change much inside of an options menu like that. If you want to make a full customization dropdown menu then you have to make all the components yourself. I'm pretty sure you can only change the text in the option element but not the surroundings and if you can you probably have to use javascript not css