MFC中如何做出一个下拉菜单并且做出不同的选项?
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MFC中如何做出一个下拉菜单并且做出不同的选项?相关的知识,希望对你有一定的参考价值。
是combo box么?具体怎么做出选项啊?
现在做出来的一运行下拉菜单是空的
一、在属性的第二页选项卡“Data(数据)”中加入数据,每行一个(按【Ctrl+Enter】换行)。
二、将控件与一个变量对应(用建立类向导,第一个下拉菜单选Ctrl,别选Value),如名称为m_myComboBox,则:
m_myComboBox.AddString("第一项");可以加入选项。本回答被提问者采纳 参考技术B 是MFC吗?
你看是不是 ComboBox_AddString(句柄。“text”)
靠。。记不清啦。。
更多ComboBox的用法http://msdn.microsoft.com/en-us/library/cc656426(VS.85).aspx
burgermenu的下降没有做出相应的反应
我有一个burgermenu问题,其中一个选项需要有一个下拉列表,但内容没有相应的响应。
下拉列表需要推送其他内容,但现在它只是重叠。
我添加了菜单栏/汉堡菜的代码低,希望你能帮助我,谢谢。
https://codepen.io/SofieH/pen/ZvveNK
header {
background: #e7e7e8;
color: #EBEBD3;
padding: 0.5em 0;
position: relative;
}
header::after {
content: '';
clear: both;
display: block;
}
.logo {
float: right;
font-size: 1rem;
margin: 0;
text-transform: uppercase;
font-weight: 700;
}
.logo span {
font-weight: 400;
}
.site-nav {
position: absolute;
top: 100%;
background: #464655;
clip-path: circle(0px at top left);
transition: clip-path ease-in-out 700ms;
/* display: none; */
}
.site-nav--open {
clip-path: circle(250% at top left);
/* display: block; */
}
.site-nav ul {
margin: 0;
padding: 0;
list-style: none;
}
.site-nav li {
border-bottom: 1px solid #575766;
}
.site-nav li:last-child {
border-bottom: none;
}
.site-nav a {
color: #EBEBD3;
display: block;
padding: 2em 4em 2em 1.5em;
text-transform: uppercase;
text-decoration: none;
}
.site-nav a:hover,
.site-nav a:focus {
background: #E4B363;
color: #464655;
}
.site-nav--icon {
display: inline-block;
font-size: 1.5em;
margin-right: 1em;
width: 1.1em;
text-align: right;
color: rgba(255, 255, 255, .4);
}
.menu-toggle {
position: absolute;
padding: 15px;
float: left;
top: 5px;
cursor: pointer;
}
.menu-toggle:hover {
cursor: pointer;
}
.hamburger,
.hamburger::before,
.hamburger::after {
content: '';
display: block;
background: #636363;
height: 3px;
width: 1.75em;
border-radius: 3px;
transition: all ease-in-out 500ms;
}
.hamburger::before {
transform: translateY(-6px);
}
.hamburger::after {
transform: translateY(3px);
}
.open .hamburger {
transform: rotate(45deg);
}
.open .hamburger::before {
opacity: 0;
}
.open .hamburger::after {
transform: translateY(-3px) rotate(-90deg);
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-treatment {
display: none;
background-color: #464655;
position: absolute;
z-index: 1;
/*min-width: 160px;*/
height: 400px;
}
.dropdown-treatment a {
padding: 2em 4em 2em 1.5em;
}
.dropdown:hover .dropdown-treatment {
display: block;
margin-left: 100px;
}
nav ul div div:hover .dropdown-other {
margin-top: 300px;
}
@media (min-width: 700px) {
.menu-toggle {
display: none;
}
.site-nav {
height: auto;
position: relative;
background: transparent;
float: right;
clip-path: initial;
}
.site-nav li {
display: inline-block;
border: none;
}
.site-nav a {
padding: 0;
margin-left: 3em;
}
.site-nav a:hover,
.site-nav a:focus {
background: transparent;
}
}
<header>
<div class="container">
<!--<h1 class="logo"><span>Logo</span></h1>-->
<h1 class="logo">Godfornuft</h1>
<nav class="site-nav">
<ul>
<li><a href="#">Forside</a></li>
<div class="dropdown">
<li><a href="zoneterapi.html">Behandlinger</a></li>
<div class="dropdown-treatment drophover">
<li>
<a href="zoneterapi.html"></a>Zoneterapi</li>
<li>
<a href="#"></a>Tankefeltterapi</li>
<li>
<a href="#"></a>Babyzoneterapi</li>
</div>
</div>
<div class="dropdown-other">
<li><a href="#">Priser</a></li>
<li><a href="#">Om Godfornuft</a></li>
<li><a href="#">Kontakt</a></li>
</div>
</ul>
</nav>
<div class="menu-toggle">
<div class="hamburger"></div>
</div>
<div class="col XS-12 logotop">
<img src="http://via.placeholder.com/200x30" alt="">
</div>
</header>
答案
尝试从position absolute
中删除.dropdown-treatment
。
请尝试仅添加li
标签作为ul
的直接孩子
阅读更多关于定位here的信息
一个样品
$('.menu-toggle').click(function() {
$('.site-nav').toggleClass('site-nav--open', 500);
$(this).toggleClass('open');
});
body {
margin:0;
padding: 0;
width: 100%;
}
header {
background: #e7e7e8;
color: #EBEBD3;
padding: 0.5em 0;
position: relative;
}
header::after {
content: '';
clear: both;
display: block;
}
.logo {
float: right;
font-size: 1rem;
margin: 0;
text-transform: uppercase;
font-weight: 700;
}
.logo span {
font-weight: 400;
}
.site-nav {
position: absolute;
top: 100%;
background: #464655;
clip-path: circle(0px at top left);
transition: clip-path ease-in-out 700ms;
/* display: none; */
}
.site-nav--open {
clip-path: circle(250% at top left);
/* display: block; */
}
.site-nav ul {
margin: 0;
padding: 0;
list-style: none;
}
.site-nav li {
border-bottom: 1px solid #575766;
}
.site-nav li:last-child {
border-bottom: none;
}
.site-nav a {
color: #EBEBD3;
display: block;
padding: 2em 4em 2em 1.5em;
text-transform: uppercase;
text-decoration: none;
}
.site-nav a:hover,
.site-nav a:focus {
background: #E4B363;
color: #464655;
}
.site-nav--icon {
display: inline-block;
font-size: 1.5em;
margin-right: 1em;
width: 1.1em;
text-align: right;
color: rgba(255,255,255,.4);
}
.menu-toggle {
position: absolute;
padding: 15px;
float: left;
top: 5px;
cursor: pointer;
}
.menu-toggle:hover {
cursor: pointer;
}
.hamburger,
.hamburger::before,
.hamburger::after {
content: '';
display: block;
background: #636363;
height: 3px;
width: 1.75em;
border-radius: 3px;
transition: all ease-in-out 500ms;
}
.hamburger::before {
transform: translateY(-6px);
}
.hamburger::after {
transform: translateY(3px);
}
.open .hamburger {
transform: rotate(45deg);
}
.open .hamburger::before {
opacity: 0;
}
.open .hamburger::after {
transform: translateY(-3px) rotate(-90deg);
}
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-treatment {
display: none;
background-color: #464655;
/*background-color: #E4B363;*/
/*position: absolute;
z-index: -20;*/
/*min-width: 160px;*/
/* height: 400px;*/
}
.dropdown-treatment a {
// padding: 2em 4em 2em 1.5em;
}
.dropdown:hover .dropdown-treatment {
display: block;
margin-left: 100px;
}
nav ul div div:hover .dropdown-other {
margin-top: 300px;
}
@media (min-width: 700px) {
.menu-toggle {
display: none;
}
.site-nav {
height: auto;
position: relative;
background: transparent;
float: right;
clip-path: initial;
}
.site-nav li {
display: inline-block;
border: none;
}
.site-nav a {
padding: 0;
margin-left: 3em;
}
.site-nav a:hover,
.site-nav a:focus {
background: transparent;
}
.site-nav--icon {
display: none;
}
}
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Godfornuft.dk</title>
<link rel="stylesheet" href="css/skeleton_mobile.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
<link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css'>
<link rel="stylesheet" href="css/costume.css">
<!--https://codepen.io/anon/pen/YYxEej?editors=1010-->
</head>
<body>
<header class="">
<div class="container">
<!--<h1 class="logo"><span>Logo</span></h1>-->
<h1 class="logo">Godfornuft</h1>
<nav class="site-nav">
<ul>
<li><a href="#">Forside</a></li>
<li class="dropdown"><a href="zoneterapi.html">Behandlinger</a>
<ul class="dropdown-treatment drophover">
<li><a href="zoneterapi.html">Zoneterapi</a></li>
<li><a href="#">Tankefeltterapi</a></li>
<li><a href="#">Babyzoneterapi</a></li>
</ul>
</li>
<li><a href="#">Priser</a></li>
<li><a href="#">Om Godfornuft</a></li>
<li><a href="#">Kontakt</a></li>
</ul>
</nav>
<div class="menu-toggle">
<div class="hamburger"></div>
</div>
<div class="col XS-12 logotop">
<img src="http://via.placeholder.com/200x30" alt="">
</div>
</header>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js'></script>
<script src="js/navbar.js"></script>
</body>
</html>
以上是关于MFC中如何做出一个下拉菜单并且做出不同的选项?的主要内容,如果未能解决你的问题,请参考以下文章