0

我正在尝试创建一个类似于http://rackspace.com的大型菜单。我已经尝试过在其他一些问题中给出的教程,但是其中一个使用了很多图像,其中一个不适用于他们链接到的 jQuery 版本。我想保留所有 CSS,但如果必须,我可以使用一些 JavaScript。

我不明白如何制作复杂的大型菜单,但只有简单的下拉菜单。如果有人可以为我提供此代码,我将非常高兴。我现在正在学习 CSS,我认为这也可以让我提高我的知识。

谢谢,

斯科特

4

5 回答 5

2

Here is a very nice looking solution a quick Google search turned up. Haven't tried it myself but looks promising: http://net.tutsplus.com/tutorials/html-css-techniques/how-to-build-a-kick-butt-css3-mega-drop-down-menu/

于 2012-07-28T01:41:07.893 回答
1

你的问题太笼统了。您想要实现的目标不会通过我们可以在这里编写的简单 HTML 和 CSS 代码来实现。

所以你可能对这个 jQuery 插件和 CSS 框架感兴趣: https ://myflashlabs.github.io/24component-bars/

它可以帮助您快速轻松地创建具有许多功能的响应式大型菜单、页眉、侧边栏和页脚,没有任何麻烦……这正是您想要的 :)

当已经有解决方案时,您不需要从一开始就自己编写代码!

于 2017-05-20T16:59:31.303 回答
0

Extremely quick sample of what you need to do:

http://jsfiddle.net/KqZd4/

I know this looks nothing like those, but that really is all the functionality you need. Just expand what is in the dropdown

于 2012-07-28T01:41:42.617 回答
0
<li class="main_list">Electronics
<ul>
<p class="category_header">Buy Any Electronics Item And Get Flat 50% OFF</p>
<ol>
<li>Mobiles</li>
<li>Item1</li>
<li>Item2</li>
</ol>

<ol>
<li>Tablets</li>
<li>Item1</li>
<li>Item2</li>
</ol>

</ul>
</li>

添加更多你想要的

然后简单的风格

#main_menu
{
background-color:#1C1C1C;
float:left;
padding:0px;
width:700px;
height:50px;
line-height:50px;
margin-left:140px;
border-radius:5px;
}
#main_menu .main_list
{
color:white;
list-style-type:none;
float:left;
border-left:1px solid #666;
padding-left:27px;
padding-right:27px;

}
#main_menu .main_list:hover
{
color:#2E9AFE;
}
.main_list ul
{
background-color:white;
width:600px;
position:absolute;
left:150px;
width:700px;
padding:0px;
float:left;
padding-bottom:10px;
}
.main_list ul p
{
color:white;
background-color:#2E9AFE;
margin:0px;
text-align:left;
padding-left:10px;
font-size:20px;
font-weight:bold;
}
.main_list ul ol
{
float:left;
padding:0px;
list-style-type:none;
margin-left:30px;
}
.main_list ul ol li
{
line-height:25px;
font-weight:bold;
font-size:16px;
color:#2E9AFE;
}

如果您有任何问题理解这里是一个完整的教程 http://talkerscode.com/webtricks/mega-dropdown-menu-like-ecommerce-using-css.php

于 2016-02-27T18:02:43.060 回答
0

尝试这个

@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css');
* {
  box-sizing: border-box;
  font-family: sans-serif;
}

body {
  margin: 0;
}

/* Style Navigation bar */
.navbar {
  display: -webkit-flex;
  display: flex;
  background-color: #e3e3e3;
}

.navbar a {
  display: block;
  text-decoration: none;
  color: black;
  padding: 1.1em 1em;
  font-size: 1.1em;
  border-bottom: 3px solid transparent;
  transition: 0.1s;
}

.navbar > a:hover, .dropdown > a:hover {
  border-bottom-color: #FA7D19;
}

/* Style Mega Menu */
.dropdown-content {
  display: none;
  position: absolute;
  width: 90%;
  left: 5%;
  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
  z-index: 1;
  overflow: hidden;
}

.dropdown-content .header {
  padding: 16px;
  color: #777;
  background: white;
}

.dropdown:hover .dropdown-content {
  display: block;
}

/* Create three equal columns that stacks next to each other */
.row {
  display: -webkit-flex;
  display: flex;
}

.column {
  width: 100%;
  padding: 10px;
  background: #f8f8f8;
}

.column a {
  color: black;
  padding: 16px;
  text-decoration: none;
  display: block;
  text-align: left;
}

.column a:hover {
  background-color: #ddd;
}

/* Makes the three columns stack on top of each other instead of 
   next to each other (when screen width is 600px or less) */
@media screen and (max-width: 600px) {
  .row {
    flex-direction: column;
  }
}
<div class="navbar">
  <a href="#">Home</a>
  <div class="dropdown">
    <a href="#">Dropdown <i class="fa fa-caret-down"></i></a>
    <div class="dropdown-content">
      <div class="header">
        <h2>Mega Menu</h2>
      </div>   
      <div class="row">
        <div class="column">
          <h3>Category 1</h3>
          <a href="#">Link 1</a>
          <a href="#">Link 2</a>
          <a href="#">Link 3</a>
        </div>
        <div class="column">
          <h3>Category 2</h3>
          <a href="#">Link 1</a>
          <a href="#">Link 2</a>
          <a href="#">Link 3</a>
        </div>
        <div class="column">
          <h3>Category 3</h3>
          <a href="#">Link 1</a>
          <a href="#">Link 2</a>
          <a href="#">Link 3</a>
        </div>
      </div>
    </div>
  </div> 
  <a href="#">Pricing</a>
</div>

<div style="padding:10px 15px;">
  <h1>Create a Mega Menu</h1>
  <p>Hover over the "Dropdown" link to see the mega menu.</p>
</div>

参考:如何创建超级菜单

于 2019-10-28T16:09:55.003 回答