本篇文章主要的介绍了关于HTML select标签的下拉框制作,还有HTML select标签的样式解析,最后还有两个html select标签的案例。接下来让我们一起看看本篇文章吧
首先我们先来看看html select下拉框样式的制作:
原生的select下拉框其实挺方便的,直接把选项写入option就能得到一个流畅的下拉框,但是原生的样式也是让人忧愁。
首先,在各大浏览器中渲染出来的样式结果也是多样化,ie下的样式更是与众不同,会根据选项位置进行滑动。
我们这里是用纯HTML制作,连层叠样式表也不要:
<!doctype html>
<html >
<head>
<meta charset="UTF-8">
<script type="js/index.js"></script>
<title>爱上源码网之下拉列表</title>
</head>
<body >
<form>
<p>下拉列表</p>
<select>
<option>html</option>
<option>php</option>
<option>python</option>
<option>其它</option>
<option>html</option>
<option>php</option>
<option>python</option>
<option>其它</option>
</select>
</form>
</body>
</html>
这个我点开之后的效果图:
![](http://freedede.oss-cn-hangzhou.aliyuncs.com/2020/9/EzyIZb.png?x-oss-process=style/syzhong)
我们已经把HTML select的下拉框已经制作完成了,接下来我们看看HTML select的其它样式思路:
1.先去掉select本身原有的样式。
2.用一个元素(div/lebal等)作为select的父元素。
3.在select父元素后面用:after做一个新的样式。
<body>
<br />
<select id="selectTravelCity" title="Select Travel Destination">
<option>爱上源码网</option>
<option>Washington DC</option>
<option>Los Angeles</option>
<option>Chicago</option>
<option>Houston</option>
<option>Philadelphia</option>
<option>Phoenix</option>
</select>
<br />
<br />
<label id="lblSelect">
<select id="selectPointOfInterest" title="Select points of interest nearby">
<option>PHP中文网</option>
<option>food beverage</option>
<option>restaurant</option>
<option>shopping</option>
<option>taxi limo</option>
<option>theatre</option>
<option>museum</option>
<option>computers</option>
</select>
</label>
</body>
这么多,虽然不是很难,但是还是要多练习的
看了上面的图片,这个的效果图也很容易能想到吧,不过我还是会给效果图的:
![](http://freedede.oss-cn-hangzhou.aliyuncs.com/2020/9/IFjeYb.png?x-oss-process=style/syzhong)
HTML select标签的两个案例分析:
案例一:如何让html里的select无法选择?
假设有一个select,里面有几个option,因为测试需要,要固定成为其中的一个option,不能选择其他,该怎么做呢?如果disabled这个select,结果就是根本没法取到值了。有没其他的方法?readonly,也是不可以的,依旧可以选择。
答案:只放一个option就可以了 或者给option加上disabled="disabled"
<form id="form1" name="form1" method="post" action="">
<select name="select">
<option>aa</option>
<option disabled="disabled">bb</option>
<option>cc</option>
</select>
</form>
案例二:怎么调整select的宽度?
答案:可以在select标签中加入style样式
<style>.s1{ width: 200px;}</style>
<select class="s1">
<OPTION>很长很长也能显示</OPTION>
<OPTION>很长很长也能显示</OPTION>
</select>
以上就是这篇文章的全部内容了,有什么疑问欢迎在下方提问。
【小编推荐】
html5 canvas标签是什么意思?canvas标签使用方法介绍
HTML中插入文本ins标签和删除文本del标签如何一起使用?(附实例)
以上就是html select下拉框样式怎么制作?html select样式详解的详细内容,更多请关注爱上源码网其它相关文章!
微信
分享
相关标签:select option html
本文原创发布爱上源码网,转载请注明出处,感谢您的尊重!
- 上一篇:html如何实现计数器以及时钟的功能代码
- 下一篇:html中表格form相关的知识讲解(代码示例)
相关文章
相关视频
- div总是被select遮挡的解决方法_经验交流
- 解决 select 挡住div的解决方法_经验交流
- jquery实现select下拉框美化特效代码
- js实现带有介绍的Select列表菜单实例_jav...
- jquery使用ul模拟select实现表单美化的...
- html select下拉框样式怎么制作?html...
- select 语句的基本使用
- select 语句的基本使用(2)
- select 语句的加强(1)-where子句加强
- 选择列表元素select
本文有爱上源码下载完入驻作者发布,如果对您版权造成侵害,可以联系本站站长管理进行维权删除,本站收到维权24小时内进行处理,谢谢您关注23ym.cn!
本站分享大量程序员技术文章以及对编程开发的初级入门教程,包括图文讲解笔记和高清视频下载~ |