Я пытаюсь сделать раскрывающийся список в своей вертикальной панели навигации. Буду очень признателен, если вы поможете мне придумать, как создать выпадающий список.
Я пытался исследовать и искать разные коды для своего проекта. Вот некоторые вещи, которые я пробовал в своем коде.
Мой HTML-код:
<div class = "menu-overlay"></div>
<div class = "side-menu-wrapper">
<a href = "#" class = "menu-close">×</a>
<ul>
<li>
<form class = "example"action = "action_page.php">
<input type = "text" placeholder = "Search.."
name = "search">
<button type = "submit">
<i class = "fa fa-search"></i>
</button>
</form>
</li>
<li>
<a href = "Index.html" target = "_blank"
rel = "nofollow">
Home
</a>
</li>
<li >
<a href = "#" target = "_blank" rel = "nofollow">
About
</a>
<ul>
<li href = "#" target = "_blank" rel = "nofollow">
<a >Introduction</a>
</li>
<li href = "#" target = "_blank" rel = "nofollow">
<a >Mission</a>
</li>
<li href = "#" target = "_blank" rel = "nofollow">
<a >Vision</a>
</li>
</ul>
</li>
<li>
<a href = "#" target = "_blank" rel = "nofollow">
Facebook
</a>
</li>
<li>
<a href = "#" target = "_blank"
rel = "nofollow">
Flickr
</a>
</li>
</ul>
</div>
Мой CSS-код:
.side-menu-wrapper {
background: rgba(0,114,187,0.7);
padding: 40px 0 0 40px;
position: fixed;
top: 0;
right: 0;
height: 100%;
z-index: 2;
transition: 0.5s;
width: 250px;
font: 20px "Courier New", Courier, monospace;
box-sizing: border-box;
}
.side-menu-wrapper > ul{
list-style:none;
padding:0;
margin:0;
overflow-y: auto;
height:95%;
}
.side-menu-wrapper > ul > li > a {
display: block;
border-bottom: 1px solid black;
padding: 6px 4px 6px 4px;
color: white;
transition: 0.3s;
text-decoration: none;
}
.side-menu-wrapper > a.menu-close {
padding: 8px 0 4px 23px;
color: white;
display: block;
margin: -30px 0 -10px -20px;
font-size: 35px;
text-decoration: none;
}
.menu-overlay {
height: 100%;
width: 0;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: rgba(0,0,0,.7);
overflow-y: auto;
overflow-x: hidden;
text-align: center;
opacity: 0;
transition: opacity 1s;
}
спасибо кстати
Обернув подменю About
с помощью класса bootstrap collapse
(больше информации здесь), это должно работать:
<a href = "#" class = "active" data-toggle = "collapse" data-target = "#sub-menu" target = "_blank" rel = "nofollow">About<span class = "ml-2" style = "font-size: 12px;">▼</span></a>
<div class = "collapse" id = "sub-menu">
<ul>
<li href = "#" target = "_blank" rel = "nofollow">
<a >Introduction</a>
</li>
<li href = "#" target = "_blank" rel = "nofollow">
<a >Mission</a>
</li>
<li href = "#" target = "_blank" rel = "nofollow">
<a >Vision</a>
</li>
</ul>
</div>
Пример ниже:
.side-menu-wrapper {
background: rgba(0,114,187,0.7);
padding: 40px 0 0 40px;
position: fixed;
top: 0;
right: 0;
height: 100%;
z-index: 2;
transition: 0.5s;
width: 250px;
font: 20px "Courier New", Courier, monospace;
box-sizing: border-box;
}
.side-menu-wrapper > ul{
list-style:none;
padding:0;
margin:0;
overflow-y: auto;
height:95%;
}
.side-menu-wrapper > ul > li > a {
display: block;
border-bottom: 1px solid black;
padding: 6px 4px 6px 4px;
color: white;
transition: 0.3s;
text-decoration: none;
}
.side-menu-wrapper > a.menu-close {
padding: 8px 0 4px 23px;
color: white;
display: block;
margin: -30px 0 -10px -20px;
font-size: 35px;
text-decoration: none;
}
.menu-overlay {
height: 100%;
width: 0;
position: fixed;
z-index: 1;
top: 0;
left: 0;
background-color: rgba(0,0,0,.7);
overflow-y: auto;
overflow-x: hidden;
text-align: center;
opacity: 0;
transition: opacity 1s;
}
<link rel = "stylesheet" href = "https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity = "sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin = "anonymous">
<script src = "https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity = "sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin = "anonymous"></script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity = "sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin = "anonymous"></script>
<script src = "https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity = "sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin = "anonymous"></script>
<div class = "menu-overlay "></div>
<div class = "side-menu-wrapper">
<a href = "#" class = "menu-close">×</a>
<ul>
<li>
<form class = "example" action = "action_page.php">
<input type = "text" placeholder = "Search.."
name = "search">
<button type = "submit">
<i class = "fa fa-search"></i>
</button>
</form>
</li>
<li>
<a href = "#" target = "_blank" rel = "nofollow">Home</a>
</li>
<li>
<a href = "#sub-menu" class = "active" data-toggle = "collapse" data-target = "#sub-menu">About<span class = "ml-2" style = "font-size: 12px;">▼</span></a>
<div class = "collapse" id = "sub-menu">
<ul>
<li href = "#" target = "_blank" rel = "nofollow">
<a >Introduction</a>
</li>
<li href = "#" target = "_blank" rel = "nofollow">
<a >Mission</a>
</li>
<li href = "#" target = "_blank" rel = "nofollow">
<a >Vision</a>
</li>
</ul>
</div>
</li>
<li>
<a href = "#" target = "_blank" rel = "nofollow">Facebook</a>
</li>
<li>
<a href = "#" target = "_blank" rel = "nofollow">Flickr</a>
</li>
</ul>
</div>
пожалуйста пришлите ссылку
и у меня есть еще один вопрос, что, если я хочу создать вспомогательную навигацию, используя ту же технику
Вот ссылка: getbootstrap.com/docs/4.3/components/collapse
Вы имеете в виду субнавигацию в текущей About
субнавигации?
ну что-то в этом роде
Я только что задал вопрос об этом
Пожалуйста! Если у вас есть вопросы о том, как работает класс
collapse
, вы можете прочитать официальную документацию, на которую я дал ссылку.