padding or space from text to underline - css

I am making a website: Website. In the menubar I have an underline when a specifi menu is active, or you hover over the menu options.
I would like that there is some px space from the menu text to the underline. How is that possible?
I tried to set a border-bottom:1px solid white, but that does not do the trick for me.
It is the following CSS the underline is on:
.wpmega-black-white .wpmm-mega-wrapper > li:hover,
.wpmega-black-white .wpmm-mega-wrapper > li.current-menu-item {
text-decoration: underline;
margin-top: 0.8em;
transition: all ease 0.3s;
-webkit-transition: all ease 0.3s;
-ms-transition: all ease 0.3s;
}

Edited
delete previous codes and modify your CSS as I wrote:
in your CSS files /css/style.css?ver=4.9.4 find and change these block of codes. please have a backup before modifinig
please note that you should not delete other parameters of elements, only change what I wrote.
.wp-megamenu-main-wrapper.wpmm-orientation-horizontal ul.wpmm-mega-wrapper > li > a {
padding: 20px 15px 10px 20px;
}
.wp-megamenu-main-wrapper.wpmm-orientation-horizontal ul.wpmm-mega-wrapper > li.current-menu-item a, .wp-megamenu-main-wrapper.wpmm-orientation-vertical ul.wpmm-mega-wrapper > li.current-menu-item a{
border-bottom: 2px solid #FFF;
}
.wp-megamenu-main-wrapper.wpmm-orientation-horizontal.wpmm-askins-wrapper ul.wpmm-mega-wrapper > li.menu-item-has-children > a:after {
top: 60%;
}
add this to your own css file
.wp-mega-menu-link:hover {
border-bottom: 2px solid #FFF;
}

text-decoration does exactly what is says it does, underline the text...you can't move the location of that underline (yet). You would have to use a positioned pseudo-element on the inner span.
For example:
ul {
list-style: none;
background: #000;
}
li {
display: inline-block;
}
li>a {
color: white;
padding: 20px 15px 20px 20px;
position: relative;
display: block;
font-size: 16px;
font-weight: 400;
font-style: normal;
line-height: 1.6;
overflow: visible;
font-family: "Work Sans", Helvetica, Arial, sans-serif;
text-transform: capitalize;
text-align: left;
text-decoration: none;
}
li>a span {
position: relative;
}
li>a span::after {
content: "";
position: absolute;
bottom: -10px;
/* adjust spacing here */
left: 0;
width: 0%;
height: 1px;
transition: width .3s ease;
background: transparent;
}
li>a.current-item span::after {
background: currentcolor;
width: 100%;
}
li>a:hover span::after {
width: 100%;
background: currentcolor;
}
<ul>
<li><span>MY TEXT HERE</span></li>
<li><span>MY NEW ITEM</span></li>
</ul>
This also means they can be animated.

Related

CSS Nav Menu set effect on current item

I am developing a website of http://hcldesign.co.uk/ and have added a nav menu effect i found and integrated it onto my site using CSS.
The only problem is I can't figure out how to have the hover effect stay when i click the menu item and then the hover effect to also show on the current/active page/menu item. When i add the code i think it should be such as :Active this breaks the menu hover effect.
Current Code used for the menu is below
`a:focus {
color: #c9c9c9 !important;
text-decoration: none;
}
#menu-primary-menu {
font-family: 'roboto', roboto, roboto;
text-align: center;
text-transform: uppercase;
font-weight: 500;
letter-spacing: 1px;
}
#menu-primary-menu * {
-webkit-box-sizing: border-box;
box-sizing: border-box;
-webkit-transition: all 0.35s ease;
transition: all 0.35s ease;
}
#menu-primary-menu li {
display: inline-block;
list-style: outside none none;
margin: 0em 1.5em;
padding: 0;
}
#menu-primary-menu a {
padding: 0.25em 0;
color: #fff;
position: relative;
text-decoration: none;
display: inline-block;
}
#menu-primary-menu a:before,
#menu-primary-menu a:after {
height: 3px;
position: absolute;
content: '';
-webkit-transition: all 0.35s ease;
transition: all 0.35s ease;
background-color: #3588dc;
width: 0;
}
#menu-primary-menu a:before {
top: 0;
left: 0;
}
#menu-primary-menu a:after {
bottom: 0;
right: 0;
}
#menu-primary-menu a:hover {
color: #fff;
}
#menu-primary-menu .active a {
color: #fff;
}
#menu-primary-menu a:hover:before,
#menu-primary-menu .current a:before,
#menu-primary-menu a:hover:after,
#menu-primary-menu .current a:after {
width: 100%;
}
#menu-primary-menu a {
font-size: 14px;
margin: -10px
}
Any help will be appreciated.
Thanks
Give each <body id="mypage-one"> a id. You also have to give your <nav> item like <li id="nav-page-one"> a id as well.
If you now going in your css that way, you'll have your effect you wish.
#mypage-one, #nav-page-one {
background-color: #2a88bd;
}
#mypage-two, #nav-page-two {
background-color: #2a88bd;
}
If your comma separated css selectors matches now, you'll get the background-color set to #2a88bd or how ever your hover effect is.
Hope you'll be successful.
I think when u using scrolling nav it's hard to do it as above. You can use jQuery to reach your goal. Look on this codepen how it works:
https://codepen.io/anon/pen/EvXVXm
$('.link').on('click', function(event) {
$('.link').removeClass('active');
$target = $(event.target);
$target.addClass('active');
});
I think it will be helpful.
Regards

border-bottom not working correctly

I have a strange problem, i have 3 tab menu items, that have text,after text i set up border-bottom, it's working fine for first-menu tab, but for other 2 it's appears over another border-bottom, but when i put code in Jsfiddle it's works correctly.. Here is my code Jsfiddle
HTML
<div class="container">
<div class="row">
<div class="col-md-12">
<header>
<h1 class="title">Title▲</h1>
</header>
<div class="menu-nav">
<nav class="subnav">
<ul class="tabs">
CSS
body {
background-color: #E5E5E5;
}
a:link{
text-decoration:none !important;
}
.title{
margin-top: 150px;
font-size: 450%;
font-weight: bold;
letter-spacing: 3px;
margin-left: 10px;
border-bottom: 1px solid #ccc;
}
.title a,
.title a:visited,
.title a:link {
color: black;
}
.title a:hover,
.title a:link {
text-decoration: none;
color: #2bb673;
}
#show-about-btn {
font-size: 40%;
margin-left: 10px;
color: #2bb673;
}
/*Navigation*/
.subnav {
height: 80px;
line-height: 3em;
border-bottom: 1px solid #ccc;
}
.subnav li {
list-style: none;
float: left;
padding: 1px 40px 1px 1px;
}
.subnav ul li a.active {
padding: 6px;
background-color: #2bb673;
color: #fff;
-webkit-border-radius: 20px;
-moz-border-radius: 20px;
-o-border-radius: 20px;
border-radius: 20px;
text-decoration: none;
}
.subnav li a {
color: #2bb673;
font-weight: 600;
font-size: 12px;
text-transform: uppercase;
position: relative;
right: 30px;
}
.subnav a:hover {
text-decoration: none;
color: black;
-webkit-transition: all .3s ease-in;
-moz-transition: all .3s ease-in;
-o-transition: all .3s ease-in;
transition: all .3s ease-in;
}
article {
font-size: 16px;
font-family: arial, sans-serif;
display: block;
border-bottom: 1px solid #ccc;
}
.tab {
position: relative;
top: 12px;
font-size: 12px;
}
.menu-nav {
display: none;
}
.tab p,h5{
padding-bottom: 25px;
}
.tab h4 {
margin-top: 5px;
font-weight: bold;
}
.tab h5 {
font-size:18px;
}
.tab img {
margin-left: 50px;
margin-bottom: 10px;
}
/*Content*/
.our-work a {
font-family: "Literaturnaya Italic";
font-style: italic;
font-weight: 400;
font-size: 46px;
margin-top: 5px;
color: black;
}
At first screen border is in correct place
At the second tab, this same border appears over another
just add class row to #about_us or better wrap your code under #about_us inside a <div class="row">..content under #about_us..</div>. Bootstrap grid system classes like .col-md-3 should always be wrapped inside .row to avoid CSS float problem
Mechanism
grid classes starting with .col- use float:left to get aligned one after other and maintain precise dimensions. So its parent will lose all height (a classic CSS float problem). Now adding class row resolves this cleanly with adding a clearfix because it adds a pseudo element with clear:both.
.row:after {
content: " ";
clear:both;
display:block;
}
Your issue is you have multiple styles as #pankajPhartiyal said.
remove this line from border-bottom: 1px solid #ccc; from article{} in styles section
Demo

Center Font Awesome Icons Vertically

How can I adjust the height of the Font Awesome social icons at the top right of this page so that they sit in the middle of the black bar and not at the bottom? Adding padding-bottom: to .social raises them but also increases the depth of the black bar which I don't want. Adding padding-bottom elsewhere has no effect. Thank you!!
.social {
padding: 0;
margin: 0;
font-size: 0;
height: 28px;
}
.image-caption .social {
height: 33px;
padding:top: 10px;
}
.social li {
display: inline-block;
margin-right: 15px;
margin-left: 15px;
}
.footer .widget.single .social li {
margin: 0 3px
}
.text-center .social li {
margin: 0 2px
}
.social li a {
display: table
}
.social li a i {
text-align: center;
padding-top: 7px;
display: table-cell;
vertical-align: middle;
color: #aaa;
background: none;
border: 1px solid #aaa;
width: 28px;
height: 28px !important;
line-height: 1;
font-size: 13px;
-webkit-transition: all 200ms ease-in;
-o-transition: all 200ms ease-in;
-moz-transition: all 200ms ease-in;
}
.social a:hover a:hover i {
background-color: #FFF
}
.social a:hover i {
color: #FFF
}

Text Not Vertically Aligned in li

I'm working on a menu and having some trouble with text not appearing the way I'd like it to.
Here is a screenshot of what I'm having trouble with. There appears to be extra space below the link—the top and bottom aren't equal. There is no padding there, either. It is just a link within an <li>. What do I have wrong?
ul {
list-style-type: none;
height: 184px;
text-align: right;
padding: 0;
font-weight: 300;
}
li {
display: inline-block;
width: 50%;
text-align: left;
}
a:link, a:active {
font-size: 16px;
color: #000;
text-decoration: none;
-webkit-transition: background-color 0.3s, border-color 0.3s;
transition: background-color 0.3s, border-color 0.3s;
line-height: 2em;
}
a:hover {
background-color: #adadad;
}
a {
width: 100%;
padding: 0 0.5em;
}
<ul>
<li>Home</li>
<li>About</li>
<li>Contact Us</li>
</ul>
I see no issues. Apply your css styles to your A tag though, not the li. Also, for clarity to see what is going on, I put a border around each a tag. Check out the fiddle, everything looks fine to me. Height in DIV's is automatic if you don't set it statically. i.e., it all looks fine, I see no extra spacing with the CSS I provided below.
http://jsfiddle.net/4dbuuuq4/
CSS
ul {
list-style-type: none;
height: 184px;
padding: 0;
font-weight: 300;
}
li a {
display: inline-block;
width: 50%;
text-align: left;
border:solid 1px #ccc;
}
li a:hover{
cursor:pointer;
background-color:#ccc;
color:#fff;
}
a:link,
a:active {
font-size: 16px;
color: #000;
text-decoration: none;
-webkit-transition: background-color 0.3s, border-color 0.3s;
transition: background-color 0.3s, border-color 0.3s;
}
a {
width: 100%;
padding: 0 0.5em;
}
You can use display: table-cell instead of inline-block and use height instead of line-height on a:
ul {
list-style-type: none;
height: 184px;
text-align: right;
padding: 0;
font-weight: 300;
}
li {
display: inline-block;
width: 50%;
text-align: left;
}
a:link,
a:active {
font-size: 16px;
color: #000;
text-decoration: none;
-webkit-transition: background-color 0.3s, border-color 0.3s;
transition: background-color 0.3s, border-color 0.3s;
}
a:hover {
background-color: #adadad;
}
ul li a {
width: 100%;
padding: 0 0.5em;
display: table-cell;
vertical-align: middle;
height: 2em;
}
<ul>
<li>Home
</li>
<li>About
</li>
<li>Contact Us
</li>
</ul>

CSS Transitions no quite behaving properly

I have some navigation links that I'm using css transitions on.
Here's the CSS...
ul.yui-nav { list-style-type: none; }
ul.yui-nav li {
display: inline-block;
text-align: center;
height: 110px;
width: 110px;
border: none;
background: none;
}
ul.yui-nav li:hover {
background: none;
border: 1px solid #ccc;
border-radius: 50%;
height: 110px;
width: 110px;
transition: all 275ms;
-moz-transition: all 275ms; /* Firefox 4 */
-webkit-transition: all 275ms; /* Safari and Chrome */
-o-transition: all 275ms; /* Opera */
}
ul.yui-nav li a {
font-style: normal;
border-radius: 50%;
height: 100px;
width: 100px;
background: #ccc;
float: left;
color: #fff;
text-decoration: none;
font-size: 50px;
font-family: 'Oswald', sans-serif;
margin: 0 11px;
font-weight: 700;
margin: 5px 5px;
}
ul.yui-nav li a span { font-size: 16px; font-weight: 400; }
And here is the HTML...
<ul class="yui-nav">
<li>Preface</li>
<li>1<br/><span>Step</span></li>
<li>2<br/><span>Step</span></li>
<li>3<br/><span>Step</span></li>
<li>4<br/><span>Step</span></li>
<li>5<br/><span>Step</span></li>
<li>Submit</li>
</ul>
And here's a JS Fiddle with this all working (Don't mind the text not looking right)...
JS Fiddle
The problem I'm having is that when you hover over the circles, during the transition the border goes from a black square to the grey circle border. I just want a grey border to come out from the circle, and I don't understand why it's not happening correctly.
I'm not sure if i underestand your question. The problem is the black color from start the animation? You can fix it in the next lines:
...
ul.yui-nav li {
...
border-color:#ccc;
}
...
Is this correct?
Add border-radius: 50%; to your ul.yui-nav li selector. This tells it it's round even though it has no border.
Demo:
ul.yui-nav li {
border-radius: 50%;
display: inline-block; 
text-align: center; 
height: 110px; 
width: 110px; 
border: none; 
background: none; 
}

Resources