Archived topic
Button in Primary Nav Menu
12 replies · Started by Janine on December 31, 2020
Hi.
I used the code in your documentation to place a button on my primary nav menu.
@media (min-width:769px) {
.main-navigation .main-nav ul li.nav-button a {
background-color: #fff;
border: 2px solid #0920d5;
color: #222;
line-height: 35px; /*this number will likely need to be adjusted*/
}
}
.button.ghost, .button.ghost:visited {
background: transparent;
border: 2px solid #FFF;
}
.button.ghost:hover,
.button.ghost:active {
background: #FFF;
color: #222;
border: 2px solid transparent;
}
I would like to do three things:
(1) I want my button to be a solid #0920d5 and then go white with a border on hover.
(2) I would also like the border radius to be a 4 or 5.
(3) I would like to have a CTA button on mobile.
Thank you.
Hi Janine,
Try to replace your css with this:
@media (min-width: 769px) {
.main-navigation .main-nav ul li.nav-button a:hover {
border: 2px solid #0920d5;
background-color: white;
border-radius: 4px;
}
.main-navigation .main-nav ul li.nav-button a {
background-color: #0920d5;
border: 2px solid #0920d5;
color: #222;
line-height: 35px;
}
}
Let me know :)
Hi.
Thank you. But not quite.
When the button is not visited I want it 0920d5 with white text and a border radius of 4.
On hover it looks fine, though.
Then use this css:
@media (min-width: 769px) {
.main-navigation .main-nav ul li.nav-button a:hover {
border: 2px solid #0920d5;
background-color: white;
border-radius: 4px;
color: #0920d5;
}
.main-navigation .main-nav ul li.nav-button a {
background-color: #0920d5;
border: 2px solid #0920d5;
border-radius: 4px;
color: white;
line-height: 35px;
}
}
Thanks for trying. But it didn't work. In fact, the button disappeared completely.
I will try something else.
BE SAFE in 2021.
That CSS shouldn't make the button disappear.
Let us know if you need another look.
Hi.
I have sent a before and after screenshots for your review.
Thank you.
Hi there,
what is the CSS class you're adding to your Button Menu item ?
In your working CSS it looks like it is btn-1 - you will need to change it to nav-button for Yings CSS to work.
Thanks, David. That got me almost there.
How can I change the colour of the button text on hover to 0920d5? Right now, when I hover, I get a blue border but the button text is white or not visible. Thank you.
Hi Janine,
Edited CSS here:
https://generatepress.com/forums/topic/button-in-primary-nav-menu/#post-1601143
Let me know :)
Thanks, Ying. I don't like this button. So I will keep searching for one.
OK, hope you'll find the one you like :)
;-))