【发布时间】:2017-10-15 13:07:51
【问题描述】:
我想为组织的 GCSE 选项创建一个网站,我目前正在使用 Notepad++ 起草它。我在这方面部分是新手。
我想创建一个可悬停的下拉列表,其中列出了所有选项,如果单击它,它会打开一张关于主题的卡片。我喜欢 Material Design 的概念,下面是部分代码:
/* Style The Dropdown Button */
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
cursor: pointer;
}
/* The container <div> - needed to position the dropdown content */
.dropdown {
position: relative;
display: inline-block;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}
/* Links inside the dropdown */
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
/* Change color of dropdown links on hover */
.dropdown-content a:hover {
background-color: #f1f1f1
}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
display: block;
}
/* Change the background color of the dropdown button when the dropdown content is shown */
.dropdown:hover .dropbtn {
background-color: #3e8e41;
}
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.indigo-pink.min.css">
<script defer src="https://code.getmdl.io/1.3.0/material.min.js"></script>
<div class="dropdown">
<button class="dropbtn">Compulsary</button>
<div class="dropdown-content">
<a href="#">English Language</a>
<a href="#">English Literature</a>
<a href="#">Mathematics</a>
</div>
</div>
然后,我还想将每个主题链接到这种卡片: https://getmdl.io/components/index.html#cards-section
我做了一张样卡:
.demo-card-wide.mdl-card {
width: 512px;
}
.demo-card-wide>.mdl-card__title {
color: #fff;
height: 176px;
background: url('https://www.tes.com/sites/default/files/maths_blackboard.jpg') center / cover;
}
.demo-card-wide>.mdl-card__menu {
color: #fff;
}
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.indigo-pink.min.css">
<script defer src="https://code.getmdl.io/1.3.0/material.min.js"></script>
<div class="demo-card-wide mdl-card mdl-shadow--2dp">
<div class="mdl-card__title">
<h2 class="mdl-card__title-text">Mathematics</h2>
</div>
<div class="mdl-card__supporting-text">
This is one of the compulsary subjects and is crucial. It involves geometry, algebra, data, and numbers.
</div>
<div class="mdl-card__actions mdl-card--border">
<a class="mdl-button mdl-button--colored mdl-js-button mdl-js-ripple-effect">
Done
</a>
</div>
</div>
如何将卡片链接到下拉选项之一,使其打开,以及如何链接卡片上的“完成”按钮以关闭卡片?
请帮帮我。
【问题讨论】:
标签: html css button material-design