Materialize CSS提供了下拉功能。它提供了几个CSS类来使ul元素成为下拉列表, 并将ul元素的id添加到button或anchor元素的data-activates属性中。
以下是类及其效果的列表:
Index | Class name | Description |
---|---|---|
1) | dropdown-content | 它用于将ul标识为实现下拉组件。 ul元素必需。 |
2) | data-activates | 用于指定下拉ul元素的ID。 |
例子
让我们以一个示例来演示下拉列表:
<
!DOCTYPE html>
<
html>
<
head>
<
title>
The Materialize Dropdowns Example<
/title>
<
meta name = "viewport" content = "width = device-width, initial-scale = 1">
<
link rel = "stylesheet"href = "https://fonts.googleapis.com/icon?family=Material+Icons">
<
link rel = "stylesheet"href = "https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.3/css/materialize.min.css">
<
script type = "text/javascript"src = "https://code.jquery.com/jquery-2.1.1.min.js">
<
/script>
<
script src = "https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.3/js/materialize.min.js">
<
/script>
<
/head>
<
body class = "container">
<
h3>
Drop Down Example<
/h3>
<
ul id = "dropdown" class = "dropdown-content">
<
li>
<
a href = "http://www.srcmini.com/#">
Inbox<
span class = "badge">
12<
/span>
<
/a>
<
/li>
<
li>
<
a href = "http://www.srcmini.com/#!">
Unread<
span class = "new badge">
4<
/span>
<
/a>
<
/li>
<
li>
<
a href = "http://www.srcmini.com/#">
Sent<
/a>
<
/li>
<
li class = "divider">
<
/li>
<
li>
<
a href = "http://www.srcmini.com/#">
Outbox<
span class = "badge">
14<
/span>
<
/a>
<
/li>
<
/ul>
<
a class = "btn dropdown-button" href = "http://www.srcmini.com/#" data-activates = "dropdown">
Mail Box<
i class = "mdi-navigation-arrow-drop-down right">
<
/i>
<
/a>
<
/body>
<
/html>
立即测试
【Materialise CSS下拉菜单】输出
文章图片
文章图片
推荐阅读
- Materialise CSS选项卡
- Materialise CSS对话框
- Materialise CSS可折叠
- Materialise CSS面试题
- Materialise CSS预加载器(进度栏)
- Materialise CSS轮播
- Materialise CSS分页
- Materialise CSS导航栏
- Materialise CSS图标