html - 在不更改格式的情况下将 CSS3 下拉菜单添加到现有菜单项

标签 html css

我在上面遇到了一些问题,真的需要一些帮助!

菜单存在的页面之一是:

https://googledrive.com/host/0By60ZMFepOvCYWNKSzlxOVJSYTA

和CSS:

/* Global properties ======================================================== */
html, body {width:100%; padding:0; margin:0;}

sup {
   vertical-align: top;
   font-size:60%;
}
body {   
    color:#6D266A;
    background-color: #FFF3CC;
    font-family: "Futura-Book";
    src: url('Futura-Book.eot');
    src: url('Futura-Book.eot?#iefix') format('embedded-opentype'),
         url('Futura-Book.woff') format('woff'),
         url('Futura-Book.ttf') format('truetype'),
         url('Futura-Book.svg#futura-bookbook') format('svg');
}

.ic {border:0;float:right;background:#FFF3CC;color:#f00;width:50%;line-height:10px;font-size:10px;margin:-220% 0 0 0;overflow:hidden;padding:0}
.mob {width:100%;}
/***********************************************************************/
a {text-decoration:none; cursor:pointer;text-decoration:none; }
a:hover {text-decoration:none;}

.button {background:url(../images/button.png) 0 0 no-repeat; color:#000; font-size:24px; line-height:30px; display:inline-block; padding: 2px 0 5px 43px;}
.button:hover {color:#579700;}

.link {color:#D2A973; text-decoration:none; }
.link:hover {text-decoration:underline;}

.link-2 {font-family: 'Futura-Book', sans-serif; font-weight:300; font-style:italic; color:#D2A973; font-size:20px; line-height:25px; text-decoration:none; }
.link-2:hover {text-decoration:underline;}
.valentines{font-family: 'Futura-Book', sans-serif; font-weight:300; font-style:italic; color:#D2A973; font-size:20px; line-height:25px; text-decoration:none; }
.clr-1 { color:#D2A973;}

.text-1 {font-weight:normal; color:#000; font-size:60px; line-height:72px;}
.text-1 strong {font-weight:normal; margin-top:-32px; display:block;}
.text-2 {font-family: 'Futura-Book', sans-serif; font-weight:300; font-style:italic; color:#6D266A; font-size:21px; line-height:35px;}

.text-3 {font-weight:normal; color:#6D266A; font-size:50px; line-height:60px;}
.text-3 span {color:#D2A973;}
.text-4 {font-family: 'Futura-Book', sans-serif; font-weight:300; font-style:italic; color:#6D266A; font-size:30px; line-height:36px; letter-spacing:-1px;}
.text-5 {font-weight:normal; color:#D2A973; font-size:50px; line-height:60px;}
.text-5 span {vertical-align: text-top; font-size:50%;}
h2 { font-size:31px; line-height:40px; color:#000; font-weight:normal; }

ul {margin:0; padding:0;list-style-image:none;}
ul.list-1 li {padding:0px 0 0px 25px; line-height:25px; background:url(../images/marker.png) 0 5px no-repeat;}
ul.list-1 li a {color:#6D266A;}
ul.list-1 li a:hover {color:#457c00;}

/******************************************************************/
.clear {clear:both; line-height:0; font-size:0; width:100%;}
.wrapper {width:100%; overflow:hidden; position:relative}
.wrap {overflow:hidden; position:relative}
.extra-wrap {overflow:hidden;}
.fleft {float:left;}
.fright {float:right;}
.img-indent {float:left; margin:4px 18px 0px 0;}    
.line-height {line-height:18px;}
.last {margin-right:0px !important; padding-right:0px !important;}

.top {padding-top:37px;}
.top-1 {margin-top:30px;}
.top-2 {margin-top:10px;}
.top-3 {margin-top:12px;}
.top-4 {margin-top:14px;}
.top-5 {margin-top:8px !important;}
.top-6 {margin-top:13px;}
.top-7 {margin-top:34px;}

.left-1 { margin-left:13px;}

.right-1 {margin-right:40px;}

.bot-0 {padding-bottom:0 !important; margin-bottom:0 !important;}

.pad-1 {margin-top:44px; margin-bottom:33px;}

.p1 {padding-bottom:25px;}
.p2 {padding-bottom:13px;}
.p3 {padding-bottom:10px;}
.p4 {padding-bottom:20px;}
.p4 span {font-weight:bold;}
.p5 {padding-bottom:12px;}

/*********************************header*************************************/
header{ width:100%; background:url(../images/header-bg.jpg) 0 0 repeat;}
header>div+div {width:100%; background:url(../images/header-bg-shadow.png) 0 bottom repeat-x; padding-bottom:17px;}
header>div+div>div {width:960px; margin:0 auto; }
h1 {display:inline-block; z-index:1111; margin:16px 0px 0 10px; position:relative; float:left;}

nav {display:inline-block; z-index:1111; position:relative; float:right;}


ul.menu {margin:28px 10px 0px 0px; display:inline-block;}
ul.menu li {float:left; line-height:30px; margin:0px 0px 0px 48px;}
ul.menu li:hover, ul.menu li.current {}
ul.menu li a {font-size:20px; line-height:30px; color:#FFF3CC; display:inline-block; }
ul.menu li a:hover , ul.menu li.current a { color:#D2A973; }

/*********************************content*************************************/

#content {width:100%;padding:0px 0px 48px 0; background:#FFF3CC;}
#mob-content {width:100%;padding:0px 0px 48px 0; background:#FFF3CC;}

.img-border {border:#fff 8px solid; padding-bottom: 10px;}

.box-1 {overflow:hidden; padding:40px 0 34px;}
.box-1 img {float:left; margin-top:-3px;}
.box-1 h2 {margin-bottom:8px;}

.box-2 {background: url(../images/line-1.gif) 0 0 repeat-x #6D266B;}
.box-2>div {background: url(../images/line-1.gif) 0 bottom repeat-x; padding:15px 0 36px 0; text-align:center;}
.box-2>div p.text-4 {margin-top:-7px;}

.box-3 {overflow:hidden; padding:12px 0 0 0;}
.box-3>div { width:180px; float:left; margin-right:25px;}
.box-3>div a.link-2 {display:inline-block; margin:15px 0 6px 0;}

.box-4 {}
.date {overflow:hidden;}
.date strong {display:inline-block; background:url(../images/date.png) 0 0 no-repeat; width:51px; height:53px; float:left; margin-right:5px;font-weight:normal; color:#000; font-size:40px; line-height:48px; text-align:center;}
.date span {font-family: 'Futura-Book', sans-serif; font-weight:300; font-style:italic; color:#000; font-size:20px; line-height:24px; display:inline-block; overflow:hidden; margin-top:21px;}

.box-5 {overflow:hidden; padding-top:8px;}
.box-5 img {margin:4px 10px 0 0;}

.box-6 {overflow:hidden; margin-top:13px;}
.box-6>div { width:290px; float:left; margin-right:35px;}
.box-6 a.link-2 {display:inline-block; margin-bottom:3px;}

.box-7 {overflow:hidden; margin-top:10px;}
.box-7>div { width:290px; float:left; margin-right:35px;}
.box-7 a.link-2 {display:inline-block; margin-bottom:3px;}

/****************************footer************************/
footer {width:950px; overflow:hidden; margin:0 auto; padding:0px 0px 20px 0; }
footer p {float:left; text-align:center; width:580px;}
.soc-icons {overflow:hidden; float:right; margin:8px 73px 0 0;}
.soc-icons span {display:inline-block; float:left;  color:#000; font-size:20px; line-height:27px; margin-right:17px;}
.soc-icons a {display:inline-block; float:left; margin-right:19px;}
.soc-icons a:hover img {opacity:0.7;}

/**********************form**********************/
.map {width:550px; height:450px;}

#form { margin: 12px 0 0px 0px; width:300px; }
#form input {border:#fff 1px solid; background:#fff;font: 13px Arial, Helvetica, sans-serif;color:#b6b6b6; font-style:italic; padding:5px 9px 6px 18px;outline: medium none;width: 300px;  float:left;}
#form textarea {border:#fff 1px solid; background:#fff;font: 13px Arial, Helvetica, sans-serif;color:#b6b6b6; font-style:italic;  height: 268px;outline: medium none;overflow: auto;padding: 6px 0px 0px 18px;width: 281px;resize:none;margin:0px 0 0 0;float:left;}
#form label {position:relative;overflow:hidden;display: block;min-height:35px;}
.btns {text-align:left;  padding-top:15px;}

我需要在主菜单的“治疗”链接下添加一个包含 3 个链接的下拉菜单,但似乎无法正常运行。

如有任何帮助,我们将不胜感激!

山姆

最佳答案

如果我没理解错的话,下面的方法应该有效:

HTML:

<body>

<ul>
    <li><a>level1</a>
        <ul>
            <li><a>level2</a></li>
        </ul>
    </li>
    <li><a>level1</a></li>
</ul>

</body>

CSS:

ul {
    position:relative;
    list-style:none;
}

ul li a {
    display:inline-block;
    float:left;
    width:100px;
    height:50px;
    background:#eaeaea;
    text-align:center;
    vertical-align:middle;
    line-height:50px;
}

ul ul {
    display:none; 
    position:absolute;
}

ul li:hover > ul {
    display:block;
    top:50px;
}

ul ul li a {
    background:#a7a7a7;   
}

这里正在运行 jsfiddle:http://jsfiddle.net/a9NVN/32/

您可以根据自己的喜好设置子菜单的 CSS 格式,独立于父元素。

希望我已经回答了你的问题!

关于html - 在不更改格式的情况下将 CSS3 下拉菜单添加到现有菜单项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21492576/

相关文章:

javascript - 如何让window.location.href执行POST请求

html - body 宽度超过 100% 仅在移动设备上

javascript - 将鼠标悬停在按钮上可加快视频速度,如果不悬停按钮,视频将恢复到相同的速度

html - 如何在 Bootstrap 中的元素左侧添加数字(日期)?

jQuery 将悬停功能转换为点击功能 - 切换?

html - overflow hidden 文本后面的文本

javascript - 获取相关元素的CSS样式

html - 如何对齐中心 Bootstrap 这个公式?

滚动时更改标题颜色的JavaScript

html - ExtJS 6 图表——改变背景颜色