WordPress vertical menu hover effect positioning
Hoping someone might be able to help me as I'm currently pulling my hair out. I've got a vertical menu in WordPress and am trying to styling to the active and hover. I've got the effect working but it's in the wrong place.
Here's the menu:
<nav class="vertical-header-menu-container"><ul id="main-menu" class="d-none d-md-block navbar-nav vertical-header-menu"><li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-home nav-item menu-item-1106 "><a title="Home" href="https://and-it.co.uk/dan/" class="nav-link"><div class="title-content">Home</div></a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-636 current_page_item nav-item menu-item-1073 active "><a title="Blog" href="https://and-it.co.uk/dan/blog/" class="nav-link"><div class="title-content">Blog</div></a></li>
</ul></nav>
And here is the CSS applied:
#main-menu .current-menu-item a::before,
#main-menu .current_page_item a::before {
content: "";
position: absolute;
left: 0;
right: 0;
}
#main-menu li a::before {
content: "";
position: absolute;
left: 0;
right: 100%;
background: #15bf86;
height: 3px;
-webkit-transition-property: right;
transition-property: right;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
-webkit-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
#main-menu li a:hover {
opacity: 1 !important;
}
#main-menu li a:hover:before {
right: 0;
}
#main-menu li li a:before {
bottom: 10%;
}
The idea is that a solid line appears below the active menu item or below the item being hovered over. It's currently above the items.
I thought I was probably using the wrong selectors but have tried changing them and no joy. I also thought that maybe I should be using 'after' instead of 'before' but again, no joy.
Would appreciate any help or direction you guys can provide.
html css wordpress
add a comment |
Hoping someone might be able to help me as I'm currently pulling my hair out. I've got a vertical menu in WordPress and am trying to styling to the active and hover. I've got the effect working but it's in the wrong place.
Here's the menu:
<nav class="vertical-header-menu-container"><ul id="main-menu" class="d-none d-md-block navbar-nav vertical-header-menu"><li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-home nav-item menu-item-1106 "><a title="Home" href="https://and-it.co.uk/dan/" class="nav-link"><div class="title-content">Home</div></a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-636 current_page_item nav-item menu-item-1073 active "><a title="Blog" href="https://and-it.co.uk/dan/blog/" class="nav-link"><div class="title-content">Blog</div></a></li>
</ul></nav>
And here is the CSS applied:
#main-menu .current-menu-item a::before,
#main-menu .current_page_item a::before {
content: "";
position: absolute;
left: 0;
right: 0;
}
#main-menu li a::before {
content: "";
position: absolute;
left: 0;
right: 100%;
background: #15bf86;
height: 3px;
-webkit-transition-property: right;
transition-property: right;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
-webkit-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
#main-menu li a:hover {
opacity: 1 !important;
}
#main-menu li a:hover:before {
right: 0;
}
#main-menu li li a:before {
bottom: 10%;
}
The idea is that a solid line appears below the active menu item or below the item being hovered over. It's currently above the items.
I thought I was probably using the wrong selectors but have tried changing them and no joy. I also thought that maybe I should be using 'after' instead of 'before' but again, no joy.
Would appreciate any help or direction you guys can provide.
html css wordpress
add a comment |
Hoping someone might be able to help me as I'm currently pulling my hair out. I've got a vertical menu in WordPress and am trying to styling to the active and hover. I've got the effect working but it's in the wrong place.
Here's the menu:
<nav class="vertical-header-menu-container"><ul id="main-menu" class="d-none d-md-block navbar-nav vertical-header-menu"><li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-home nav-item menu-item-1106 "><a title="Home" href="https://and-it.co.uk/dan/" class="nav-link"><div class="title-content">Home</div></a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-636 current_page_item nav-item menu-item-1073 active "><a title="Blog" href="https://and-it.co.uk/dan/blog/" class="nav-link"><div class="title-content">Blog</div></a></li>
</ul></nav>
And here is the CSS applied:
#main-menu .current-menu-item a::before,
#main-menu .current_page_item a::before {
content: "";
position: absolute;
left: 0;
right: 0;
}
#main-menu li a::before {
content: "";
position: absolute;
left: 0;
right: 100%;
background: #15bf86;
height: 3px;
-webkit-transition-property: right;
transition-property: right;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
-webkit-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
#main-menu li a:hover {
opacity: 1 !important;
}
#main-menu li a:hover:before {
right: 0;
}
#main-menu li li a:before {
bottom: 10%;
}
The idea is that a solid line appears below the active menu item or below the item being hovered over. It's currently above the items.
I thought I was probably using the wrong selectors but have tried changing them and no joy. I also thought that maybe I should be using 'after' instead of 'before' but again, no joy.
Would appreciate any help or direction you guys can provide.
html css wordpress
Hoping someone might be able to help me as I'm currently pulling my hair out. I've got a vertical menu in WordPress and am trying to styling to the active and hover. I've got the effect working but it's in the wrong place.
Here's the menu:
<nav class="vertical-header-menu-container"><ul id="main-menu" class="d-none d-md-block navbar-nav vertical-header-menu"><li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-home nav-item menu-item-1106 "><a title="Home" href="https://and-it.co.uk/dan/" class="nav-link"><div class="title-content">Home</div></a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-636 current_page_item nav-item menu-item-1073 active "><a title="Blog" href="https://and-it.co.uk/dan/blog/" class="nav-link"><div class="title-content">Blog</div></a></li>
</ul></nav>
And here is the CSS applied:
#main-menu .current-menu-item a::before,
#main-menu .current_page_item a::before {
content: "";
position: absolute;
left: 0;
right: 0;
}
#main-menu li a::before {
content: "";
position: absolute;
left: 0;
right: 100%;
background: #15bf86;
height: 3px;
-webkit-transition-property: right;
transition-property: right;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
-webkit-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
#main-menu li a:hover {
opacity: 1 !important;
}
#main-menu li a:hover:before {
right: 0;
}
#main-menu li li a:before {
bottom: 10%;
}
The idea is that a solid line appears below the active menu item or below the item being hovered over. It's currently above the items.
I thought I was probably using the wrong selectors but have tried changing them and no joy. I also thought that maybe I should be using 'after' instead of 'before' but again, no joy.
Would appreciate any help or direction you guys can provide.
html css wordpress
html css wordpress
asked Nov 11 at 20:07
Dan Anderton
1
1
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
To my understanding, this is what you expected
#main-menu li a::after {
content: "";
position: absolute;
left: 0;
right: 100%;
background: #15bf86;
height: 3px;
-webkit-transition-property: right;
transition-property: right;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
-webkit-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
#main-menu li a:hover {
opacity: 1 !important;
}
#main-menu li a:hover:after {
right: 0;
}
#main-menu li li a:after {
bottom: 10%;
}
<nav class="vertical-header-menu-container"><ul id="main-menu" class="d-none d-md-block navbar-nav vertical-header-menu"><li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-home nav-item menu-item-1106 "><a title="Home" href="https://and-it.co.uk/dan/" class="nav-link"><div class="title-content">Home</div></a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-636 current_page_item nav-item menu-item-1073 active "><a title="Blog" href="https://and-it.co.uk/dan/blog/" class="nav-link"><div class="title-content">Blog</div></a></li>
</ul></nav>
Running the code snippet and it works exactly as I expected. Using your CSS on my actual site however results in the same thing my code did... the lines appear above the menu item instead of below. My guess now is that this is conflicting with something else on the site perhaps?
– Dan Anderton
Nov 12 at 13:58
So that, if it's possible to give the site link..which i'll try to figure it out.
– a.prakash
Nov 13 at 3:54
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53252730%2fwordpress-vertical-menu-hover-effect-positioning%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
To my understanding, this is what you expected
#main-menu li a::after {
content: "";
position: absolute;
left: 0;
right: 100%;
background: #15bf86;
height: 3px;
-webkit-transition-property: right;
transition-property: right;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
-webkit-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
#main-menu li a:hover {
opacity: 1 !important;
}
#main-menu li a:hover:after {
right: 0;
}
#main-menu li li a:after {
bottom: 10%;
}
<nav class="vertical-header-menu-container"><ul id="main-menu" class="d-none d-md-block navbar-nav vertical-header-menu"><li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-home nav-item menu-item-1106 "><a title="Home" href="https://and-it.co.uk/dan/" class="nav-link"><div class="title-content">Home</div></a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-636 current_page_item nav-item menu-item-1073 active "><a title="Blog" href="https://and-it.co.uk/dan/blog/" class="nav-link"><div class="title-content">Blog</div></a></li>
</ul></nav>
Running the code snippet and it works exactly as I expected. Using your CSS on my actual site however results in the same thing my code did... the lines appear above the menu item instead of below. My guess now is that this is conflicting with something else on the site perhaps?
– Dan Anderton
Nov 12 at 13:58
So that, if it's possible to give the site link..which i'll try to figure it out.
– a.prakash
Nov 13 at 3:54
add a comment |
To my understanding, this is what you expected
#main-menu li a::after {
content: "";
position: absolute;
left: 0;
right: 100%;
background: #15bf86;
height: 3px;
-webkit-transition-property: right;
transition-property: right;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
-webkit-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
#main-menu li a:hover {
opacity: 1 !important;
}
#main-menu li a:hover:after {
right: 0;
}
#main-menu li li a:after {
bottom: 10%;
}
<nav class="vertical-header-menu-container"><ul id="main-menu" class="d-none d-md-block navbar-nav vertical-header-menu"><li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-home nav-item menu-item-1106 "><a title="Home" href="https://and-it.co.uk/dan/" class="nav-link"><div class="title-content">Home</div></a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-636 current_page_item nav-item menu-item-1073 active "><a title="Blog" href="https://and-it.co.uk/dan/blog/" class="nav-link"><div class="title-content">Blog</div></a></li>
</ul></nav>
Running the code snippet and it works exactly as I expected. Using your CSS on my actual site however results in the same thing my code did... the lines appear above the menu item instead of below. My guess now is that this is conflicting with something else on the site perhaps?
– Dan Anderton
Nov 12 at 13:58
So that, if it's possible to give the site link..which i'll try to figure it out.
– a.prakash
Nov 13 at 3:54
add a comment |
To my understanding, this is what you expected
#main-menu li a::after {
content: "";
position: absolute;
left: 0;
right: 100%;
background: #15bf86;
height: 3px;
-webkit-transition-property: right;
transition-property: right;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
-webkit-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
#main-menu li a:hover {
opacity: 1 !important;
}
#main-menu li a:hover:after {
right: 0;
}
#main-menu li li a:after {
bottom: 10%;
}
<nav class="vertical-header-menu-container"><ul id="main-menu" class="d-none d-md-block navbar-nav vertical-header-menu"><li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-home nav-item menu-item-1106 "><a title="Home" href="https://and-it.co.uk/dan/" class="nav-link"><div class="title-content">Home</div></a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-636 current_page_item nav-item menu-item-1073 active "><a title="Blog" href="https://and-it.co.uk/dan/blog/" class="nav-link"><div class="title-content">Blog</div></a></li>
</ul></nav>
To my understanding, this is what you expected
#main-menu li a::after {
content: "";
position: absolute;
left: 0;
right: 100%;
background: #15bf86;
height: 3px;
-webkit-transition-property: right;
transition-property: right;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
-webkit-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
#main-menu li a:hover {
opacity: 1 !important;
}
#main-menu li a:hover:after {
right: 0;
}
#main-menu li li a:after {
bottom: 10%;
}
<nav class="vertical-header-menu-container"><ul id="main-menu" class="d-none d-md-block navbar-nav vertical-header-menu"><li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-home nav-item menu-item-1106 "><a title="Home" href="https://and-it.co.uk/dan/" class="nav-link"><div class="title-content">Home</div></a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-636 current_page_item nav-item menu-item-1073 active "><a title="Blog" href="https://and-it.co.uk/dan/blog/" class="nav-link"><div class="title-content">Blog</div></a></li>
</ul></nav>
#main-menu li a::after {
content: "";
position: absolute;
left: 0;
right: 100%;
background: #15bf86;
height: 3px;
-webkit-transition-property: right;
transition-property: right;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
-webkit-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
#main-menu li a:hover {
opacity: 1 !important;
}
#main-menu li a:hover:after {
right: 0;
}
#main-menu li li a:after {
bottom: 10%;
}
<nav class="vertical-header-menu-container"><ul id="main-menu" class="d-none d-md-block navbar-nav vertical-header-menu"><li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-home nav-item menu-item-1106 "><a title="Home" href="https://and-it.co.uk/dan/" class="nav-link"><div class="title-content">Home</div></a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-636 current_page_item nav-item menu-item-1073 active "><a title="Blog" href="https://and-it.co.uk/dan/blog/" class="nav-link"><div class="title-content">Blog</div></a></li>
</ul></nav>
#main-menu li a::after {
content: "";
position: absolute;
left: 0;
right: 100%;
background: #15bf86;
height: 3px;
-webkit-transition-property: right;
transition-property: right;
-webkit-transition-duration: 0.3s;
transition-duration: 0.3s;
-webkit-transition-timing-function: ease-out;
transition-timing-function: ease-out;
}
#main-menu li a:hover {
opacity: 1 !important;
}
#main-menu li a:hover:after {
right: 0;
}
#main-menu li li a:after {
bottom: 10%;
}
<nav class="vertical-header-menu-container"><ul id="main-menu" class="d-none d-md-block navbar-nav vertical-header-menu"><li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-home nav-item menu-item-1106 "><a title="Home" href="https://and-it.co.uk/dan/" class="nav-link"><div class="title-content">Home</div></a></li>
<li class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-636 current_page_item nav-item menu-item-1073 active "><a title="Blog" href="https://and-it.co.uk/dan/blog/" class="nav-link"><div class="title-content">Blog</div></a></li>
</ul></nav>
answered Nov 12 at 12:28
a.prakash
513
513
Running the code snippet and it works exactly as I expected. Using your CSS on my actual site however results in the same thing my code did... the lines appear above the menu item instead of below. My guess now is that this is conflicting with something else on the site perhaps?
– Dan Anderton
Nov 12 at 13:58
So that, if it's possible to give the site link..which i'll try to figure it out.
– a.prakash
Nov 13 at 3:54
add a comment |
Running the code snippet and it works exactly as I expected. Using your CSS on my actual site however results in the same thing my code did... the lines appear above the menu item instead of below. My guess now is that this is conflicting with something else on the site perhaps?
– Dan Anderton
Nov 12 at 13:58
So that, if it's possible to give the site link..which i'll try to figure it out.
– a.prakash
Nov 13 at 3:54
Running the code snippet and it works exactly as I expected. Using your CSS on my actual site however results in the same thing my code did... the lines appear above the menu item instead of below. My guess now is that this is conflicting with something else on the site perhaps?
– Dan Anderton
Nov 12 at 13:58
Running the code snippet and it works exactly as I expected. Using your CSS on my actual site however results in the same thing my code did... the lines appear above the menu item instead of below. My guess now is that this is conflicting with something else on the site perhaps?
– Dan Anderton
Nov 12 at 13:58
So that, if it's possible to give the site link..which i'll try to figure it out.
– a.prakash
Nov 13 at 3:54
So that, if it's possible to give the site link..which i'll try to figure it out.
– a.prakash
Nov 13 at 3:54
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53252730%2fwordpress-vertical-menu-hover-effect-positioning%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown