- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
你知道如何让子菜单出现在主菜单的左侧吗?当它突然从右边弹出到任何地方时..我在这里有点紧张。我必须承认这一切都不是我自己写的,所以我不确定在哪里或如何改变它。我希望您不要介意 - 这是我定制的免费使用。
我真的很感激帮助。提前非常感谢您!
/*navmenu-right*/
var mcVM_options = {
menuId: "menu-vr",
alignWithMainMenu: false
};
/* www.menucool.com/vertical/vertical-menu.*/
init_v_menu(mcVM_options);
function init_v_menu(a) {
if (window.addEventListener) window.addEventListener("load", function() {
start_v_menu(a)
}, false);
else window.attachEvent && window.attachEvent("onload", function() {
start_v_menu(a)
})
}
function start_v_menu(i) {
var e = document.getElementById(i.menuId),
j = e.offsetHeight,
b = e.getElementsByTagName("ul"),
g = /msie|MSIE 6/.test(navigator.userAgent);
if (g)
for (var h = e.getElementsByTagName("li"), a = 0, l = h.length; a < l; a++) {
h[a].onmouseover = function() {
this.className = "onhover"
};
h[a].onmouseout = function() {
this.className = ""
}
}
for (var k = function(a, b) {
if (a.id == i.menuId) return b;
else {
b += a.offsetTop;
return k(a.parentNode.parentNode, b)
}
}, a = 0; a < b.length; a++) {
var c = b[a].parentNode;
c.getElementsByTagName("a")[0].className += " arrow";
b[a].style.left = c.offsetWidth + "px";
b[a].style.top = c.offsetTop + "px";
if (i.alignWithMainMenu) {
var d = k(c.parentNode, 0);
if (b[a].offsetTop + b[a].offsetHeight + d > j) {
var f;
if (b[a].offsetHeight > j) f = -d;
else f = j - b[a].offsetHeight - d;
b[a].style.top = f + "px"
}
}
c.onmouseover = function() {
if (g) this.className = "onhover";
var a = this.getElementsByTagName("ul")[0];
if (a) {
a.style.visibility = "visible";
a.style.display = "block";
}
};
c.onmouseout = function() {
if (g) this.className = "";
this.getElementsByTagName("ul")[0].style.visibility = "hidden";
this.getElementsByTagName("ul")[0].style.display = "none"
}
}
for (var a = b.length - 1; a > -1; a--) b[a].style.display = "none"
}
/*nav-menu right*/
#menu-vr,
#menu-vr ul {
width: 200px;
position: relative;
font-size: 0;
list-style: none;
margin: 0;
padding: 0;
display: block;
z-index: 9;
margin-top: 135px;
float: right;
text-align: right;
}
/* Top level menu links style
---------------------------------------*/
#menu-vr li {
background: url(bg.gif) repeat-x 0 2px;
list-style: none;
margin: 0;
padding: 0;
}
#menu-vr li a {
font: normal 17px Gitan Latin;
display: block;
color: black;
text-decoration: none;
line-height: 39px;
padding-right: 26px;
border: none;
}
#menu-vr ul li a {
line-height: 39px;
}
#menu-vr li a.arrow:hover {
background-image: url(../assets/ringsenberg-menue-pfeil-links.svg);
background-repeat: no-repeat;
background-position: 30px 12px;
}
/*Sub level menu items
---------------------------------------*/
#menu-vr li ul {
position: absolute;
width: 200px;
/*Sub Menu Items width */
visibility: hidden;
margin: 0px;
}
#menu-vr a.arrow {
background-image: url(../assets/ringsenberg-menue-pfeil-links.svg);
background-repeat: no-repeat;
background-position: 30px 12px;
}
#menu-vr li:hover,
#menu-vr li.onhover {
transition: all .5s;
background: rgba(198, 156, 109, .2);
border-bottom: solid;
border-width: 1px;
border-color: #C69C6D;
}
#menu-vr ul li {
background: none;
}
#menu-vr ul li:hover,
#menu-vr ul li.onhover {
background: #FFF;
background: rgba(198, 156, 109, .2);
border-right: solid;
border-width: 1px;
border-color: #C69C6D;
}
#menu-vr li a.top {
color: white;
transition: all .5s;
}
#menu-vr li a.top:hover {
color: black;
background: rgba(226, 205, 182, 1)
}
<ul id="menu-vr">
<li><a href="#" class="top">Home</a></li>
<li><a href="#">a</a>
<ul class="sub">
<li><a href="vertical-menu#1">Vertical Menu</a></li>
<li><a href="vertical-menu#2">Vertical Menus</a></li>
</ul>
</li>
<li><a href="#">ab</a>
<ul class="sub">
<li><a href="#">Sub Item 3.1</a></li>
<li><a href="#">Sub Item 3.2</a></li>
<li><a href="#">Sub Item 3.3</a></li>
<li><a href="#">Sub Item 3.4</a></li>
<li><a href="#">Sub Item 3.5</a></li>
</ul>
</li>
<li><a href="#">abc</a></li>
<li><a href="#">abcd</a>
<ul class="sub">
<li><a href="#">Sub Item 5.1</a></li>
<li><a href="#">Sub Item 5.2</a></li>
<li><a href="#">Sub Item 5.3</a></li>
</ul>
</li>
</ul>
最佳答案
子菜单出现在右侧是因为脚本设置子菜单
位置从左到右,需要将其更改为从右到左。
更改了b[a].style.left = c.offsetWidth + "px";
至b[a].style.right = c.offsetWidth + "px";
/*navmenu-right*/
var mcVM_options = {
menuId: "menu-vr",
alignWithMainMenu: false
};
/* www.menucool.com/vertical/vertical-menu.*/
init_v_menu(mcVM_options);
function init_v_menu(a) {
if (window.addEventListener) window.addEventListener("load", function() {
start_v_menu(a)
}, false);
else window.attachEvent && window.attachEvent("onload", function() {
start_v_menu(a)
})
}
function start_v_menu(i) {
var e = document.getElementById(i.menuId),
j = e.offsetHeight,
b = e.getElementsByTagName("ul"),
g = /msie|MSIE 6/.test(navigator.userAgent);
if (g)
for (var h = e.getElementsByTagName("li"), a = 0, l = h.length; a < l; a++) {
h[a].onmouseover = function() {
this.className = "onhover"
};
h[a].onmouseout = function() {
this.className = ""
}
}
for (var k = function(a, b) {
if (a.id == i.menuId) return b;
else {
b += a.offsetTop;
return k(a.parentNode.parentNode, b)
}
}, a = 0; a < b.length; a++) {
var c = b[a].parentNode;
c.getElementsByTagName("a")[0].className += " arrow";
b[a].style.right = c.offsetWidth + "px";
b[a].style.top = c.offsetTop + "px";
if (i.alignWithMainMenu) {
var d = k(c.parentNode, 0);
if (b[a].offsetTop + b[a].offsetHeight + d > j) {
var f;
if (b[a].offsetHeight > j) f = -d;
else f = j - b[a].offsetHeight - d;
b[a].style.top = f + "px"
}
}
c.onmouseover = function() {
if (g) this.className = "onhover";
var a = this.getElementsByTagName("ul")[0];
if (a) {
a.style.visibility = "visible";
a.style.display = "block";
}
};
c.onmouseout = function() {
if (g) this.className = "";
this.getElementsByTagName("ul")[0].style.visibility = "hidden";
this.getElementsByTagName("ul")[0].style.display = "none"
}
}
for (var a = b.length - 1; a > -1; a--) b[a].style.display = "none"
}
/*nav-menu right*/
#menu-vr,
#menu-vr ul {
width: 200px;
position: relative;
font-size: 0;
list-style: none;
margin: 0;
padding: 0;
display: block;
z-index: 9;
margin-top: 135px;
float: right;
text-align: right;
}
/* Top level menu links style
---------------------------------------*/
#menu-vr li {
background: url(bg.gif) repeat-x 0 2px;
list-style: none;
margin: 0;
padding: 0;
}
#menu-vr li a {
font: normal 17px Gitan Latin;
display: block;
color: black;
text-decoration: none;
line-height: 39px;
padding-right: 26px;
border: none;
}
#menu-vr ul li a {
line-height: 39px;
}
#menu-vr li a.arrow:hover {
background-image: url(../assets/ringsenberg-menue-pfeil-links.svg);
background-repeat: no-repeat;
background-position: 30px 12px;
}
/*Sub level menu items
---------------------------------------*/
#menu-vr li ul {
position: absolute;
width: 200px;
/*Sub Menu Items width */
visibility: hidden;
margin: 0px;
}
#menu-vr a.arrow {
background-image: url(../assets/ringsenberg-menue-pfeil-links.svg);
background-repeat: no-repeat;
background-position: 30px 12px;
}
#menu-vr li:hover,
#menu-vr li.onhover {
transition: all .5s;
background: rgba(198, 156, 109, .2);
border-bottom: solid;
border-width: 1px;
border-color: #C69C6D;
}
#menu-vr ul li {
background: none;
}
#menu-vr ul li:hover,
#menu-vr ul li.onhover {
background: #FFF;
background: rgba(198, 156, 109, .2);
border-right: solid;
border-width: 1px;
border-color: #C69C6D;
}
#menu-vr li a.top {
color: white;
transition: all .5s;
}
#menu-vr li a.top:hover {
color: black;
background: rgba(226, 205, 182, 1)
}
<ul id="menu-vr">
<li><a href="#" class="top">Home</a></li>
<li><a href="#">a</a>
<ul class="sub">
<li><a href="vertical-menu#1">Vertical Menu</a></li>
<li><a href="vertical-menu#2">Vertical Menus</a></li>
</ul>
</li>
<li><a href="#">ab</a>
<ul class="sub">
<li><a href="#">Sub Item 3.1</a></li>
<li><a href="#">Sub Item 3.2</a></li>
<li><a href="#">Sub Item 3.3</a></li>
<li><a href="#">Sub Item 3.4</a></li>
<li><a href="#">Sub Item 3.5</a></li>
</ul>
</li>
<li><a href="#">abc</a></li>
<li><a href="#">abcd</a>
<ul class="sub">
<li><a href="#">Sub Item 5.1</a></li>
<li><a href="#">Sub Item 5.2</a></li>
<li><a href="#">Sub Item 5.3</a></li>
</ul>
</li>
</ul>
关于javascript - 如何让子菜单出现在该导航菜单中的菜单左侧?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45629584/
我正在使用这段代码: border-right:0px solid #ddd; height:85px; box-shadow :5px 5px 10px 1px #eaeaea; 但我刚刚得到
我遇到的问题是将文本放在图像的左侧... HTML 和 CSS h2, social-hand { font-family: 'PT Sans', sans-serif; display: i
美好的一天 我今天的 CSS 很糟糕。我有 3 列 div(水平,这就是我使用 float 的原因),但我想将我的文本居中对齐,但在包含列 div 的左侧。 HTML:
在我的应用程序中,我在截取屏幕截图时在我的 Imageview 中获得了透明像素。如何剪切顶部、左侧、右侧 和 Imageview 的底部。我尝试了下面的代码但没有工作 Bitmap bitmap =
如何在左侧的以下 LinearLayout 内部添加边框,使其宽度为 5dp 并适合 LinearLayout 的整个高度? LinearLayout 的高度是动态的,这意味着有时它可以是 50dp
我是第一次做网站。我在使用下拉菜单时遇到问题。它正在向左侧移动。请帮助我处理代码,使其位于导航菜单的正下方,并且将鼠标悬停在其上时应该可见。提前致谢。 这是我的 CSS 代码: ul { li
我对 html 和 css 有点生疏,我无法让 2 个图像 float ,一个在另一个之上。这是代码...   &nbs
我有一个固定宽度 (px) 的左侧边栏,右侧是我的主要内容。 这是我的演示:http://jsfiddle.net/fxWg7/4031/ 代码如下: 这是我的 html 代码: left co
所以我正在尝试做一个弹出式菜单,但我遇到了一点问题。 我已经申请了: .menu-side, .menu { -webkit-transition: left 0.2s ease; -
在下面的 CSS @media screen and (max-width: 750px) { .flexbox { display: block; } .menu ul {
@import 'https://fonts.googleapis.com/css?family=PT+Sans'; * { font-family: 'PT Sans', sans-serif
我想在我的标题旁边放一个图标。但它不合适..我怎样才能让它合适? My heading 最佳答案 使用vertical-align:middle,因此如果您更改文本或图像的大小,位
我正在使用参数方程围绕一个圆定位图像 ( How do I calculate a point on a circle’s circumference? ) 我使用简单的数学方法以更少的方式完成此操作
我想使用外部列表属性将 ul 列表正确定位在左浮动 img 的右侧,但元素符号未在图像右侧对齐,因为没有任何图像,但更多在左边。 Lorem ipsum dolor sit amet, c
我有一个layer-list.xml 现在我想在运行时更改 (top,right) 等项目的
我通过按:M-x linum-mode 来启用它们。如何将其“翻译”到 my.emacs 文件中,以便每次打开 EMACS 时自动启用它? 最佳答案 如果您希望每个缓冲区都使用它,请将 (global
我的Code : HTML 1 2 3 CSS #score { height:50px; } .myDiv { width:40px; height:40px;
我可以轻松设置 canvas.width 和 canvas.height 属性。我找不到正确的 JavaScript 语法来使用顶部和左侧设置 Canvas 的偏移量。我尝试过直接在 Canvas 上
我正在尝试为我正在编写的单人纸牌游戏完成条件游戏。 我把所有的 Action 和棋子都移除了。每一 block 都作为椭圆 UI 元素保存在一个二维数组中,当一 block 被拿走时,它会被替换为边框
我正在使用导航 View 修改 Android 应用程序。对于前几个菜单项,我给出了一个图标,但之后,我只给出了菜单标题。但是在导航面板中,没有图标的菜单项有一个空白区域。 如何删除空白区域?我希望菜
我是一名优秀的程序员,十分优秀!