I am trying to set a fixed bar menu in my webpage, with with a transition, not an instant transition, but a 1s transition. Here I leave the code
http://jsfiddle.net/t2fPk/
.sf-menu {
border-bottom: 3px solid #333;
background: #000;
position: relative;
padding: 0;
width: 100%;
}
.sf-menu > li {
border-right: 1px solid #333;
margin-bottom: -3px;
float:left;
}
.sf-menu > li > a {
border-bottom: 0px;
color: #B3B3B3;
font-family: 'Handlee', cursive;
font-weight: 500;
font-size: 28px;
text-transform: none;
font: 600 18px/22px "Open Sans", sans-serif;
color: #484848;
display: block;
padding: 17px 20px;
}
Something like this, but i can't get it
http://jsfiddle.net/ShL4T/8/
What kind of transition are you trying to do? I added a simple background color change to yours, fiddle
.sf-menu {
border-bottom: 3px solid #333;
background: #000;
position: relative;
padding: 0;
width: 100%;
}
.sf-menu > li {
border-right: 1px solid #333;
margin-bottom: -3px;
float:left;
}
.sf-menu > li > a {
border-bottom: 0px;
color: #B3B3B3;
font-family: 'Handlee', cursive;
font-weight: 500;
font-size: 28px;
text-transform: none;
font: 600 18px/22px "Open Sans", sans-serif;
color: #484848;
display: block;
padding: 17px 20px;
background-color:green;
}
.sf-menu > li > a:hover{
transition: background-color 1s ease;
background-color: red;
}
Here is a nice article on CSS transitions that should help http://css-tricks.com/almanac/properties/t/transition/
If you want to do nice animations I recommend looking into the javascript library Greensock. It's really fast and does a nice job of animation.
Noticing your class tags I'm guessing you might be using the Superfish navigation plugin.
If so, the best way to animate would be done inside their JavaScript file. Here's a link to the documentation:
http://users.tpg.com.au/j_birch/plugins/superfish/options/
The animation ones you want to use are:
speed: 'normal'
speedOut: 'fast'
Related
I have a navigation bar that includes the usual links, and to improve the user experience I have a bottom border show on hover:
I achieve this with the following code:
body {
background-color: #E9EBEE;
color: #666666;
margin: 0px;
font-family: 'Open Sans', Helvetica, Arial, sans-serif;
font-size: 16px;
}
.nav {
padding-top: 50px;
padding-bottom: 5px;
margin-top: 2em;
margin-bottom: 6em;
background-color: #F6F7F9;
color: #666666;
font-size: 1.5em;
line-height: 1.5;
text-align: center;
}
.nav > .links {
margin-top: -36px;
border-left: solid 1px #E9EBEE;
font-size: 0.8em;
}
.nav > .links > .link {
float: left;
position: inherit;
border-right: solid 1px #E9EBEE;
border-bottom-width: 2px;
width: 8em;
transition: border-color .2s;
}
.nav > .links > .link:hover {
border-bottom: solid;
border-bottom-color: #3B5998;
border-bottom-width: 2px;
color: #3B5998;
}
<body>
<div class="nav">
<div class="links">
<div class="link">
Servers
</div>
</div>
</div>
</body>
I'd like the border to be on the bottom of nav; to do this I added padding-bottom:11px; to .nav > .links > .link, which resulted in this:
The result is exactly what I wanted, however notice that the right and left borders of each navigation item has been extended; something that I should've realised would happen when adding the padding-bottom attribute to .nav > .links > .link.
To fix this I thought that I could use a border-bottom-height since there is a border-bottom-width but apparently no such thing exists, and I don't want to use an additional element if possible to provide the left & right borders. As seen in the first image, the left and right borders should be approximately the height of the text contained.
Is this possible without an additional 'wrapper' element?
Use a pseudo element instead, i.e. ::after (if to support IE8, use :after, works cross browser)
body {
background-color: #E9EBEE;
color: #666666;
margin: 0px;
font-family: 'Open Sans', Helvetica, Arial, sans-serif;
font-size: 16px;
}
.nav {
padding-top: 50px;
padding-bottom: 5px;
margin-top: 2em;
margin-bottom: 6em;
background-color: #F6F7F9;
color: #666666;
font-size: 1.5em;
line-height: 1.5;
text-align: center;
}
.nav > .links {
margin-top: -36px;
border-left: solid 1px #E9EBEE;
font-size: 0.8em;
}
.nav > .links > .link {
float: left;
position: relative;
border-right: solid 1px #E9EBEE;
border-bottom-width: 2px;
width: 8em;
transition: border-color .2s;
}
.nav > .links > .link:hover::after {
content: '';
position: absolute;
top: calc(100% + 11px);
left: 0;
width: 100%;
height: 2px;
background: #3B5998;
}
<body>
<div class="nav">
<div class="links">
<div class="link">
Servers
</div>
</div>
</div>
</body>
There are many ways to do this. In most cases, the simplest and cleanest option would be to create a pseudo-element (as suggested by LGSon), but sometimes this isn't possible. For example, you may already have used both pseudo-elements for other effects, or you may not be able to position it properly (notice that the pseudo-element method requires you to set the .link element's position property to relative -- this may not always be possible for your layout).
Below is an alternative technique, using box-shadow. It has its own drawbacks, most notably that it only works when working with a solid-color background.
The idea is simple: draw two box-shadows (since they can stack!) on the hovered element. The bottom one is two pixels taller than the top one. The bottom one is blue, the top one is the same color as the nav bar.
body {
background-color: #E9EBEE;
color: #666666;
margin: 0px;
font-family: 'Open Sans', Helvetica, Arial, sans-serif;
font-size: 16px;
}
.nav {
padding-top: 50px;
padding-bottom: 5px;
margin-top: 2em;
margin-bottom: 6em;
background-color: #F6F7F9;
color: #666666;
font-size: 1.5em;
line-height: 1.5;
text-align: center;
}
.nav > .links {
margin-top: -36px;
border-left: solid 1px #E9EBEE;
font-size: 0.8em;
}
.nav > .links > .link {
float: left;
position: inherit;
border-right: solid 1px #E9EBEE;
border-bottom-width: 2px;
width: 8em;
transition: border-color .2s;
}
.nav > .links > .link:hover {
color: #3B5998;
box-shadow:
0 11px 0 #F6F7F9,
0 13px 0 #3B5998;
}
<body>
<div class="nav">
<div class="links">
<div class="link">
Servers
</div>
</div>
</div>
</body>
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
I'm experiencing a strange hover behavior on a link inside a list in Chrome.
I've managed to replicate the issue in this jsFiddle copying the whole html and css from the website.
The problem is on the first element of the side menu, which is the link with "Maria Montessori" in it. What happens is that the hover area is like interrupted in the middle, where the text is. It's like there is something covering the middle part of the button. Try it yourself to understand what I mean.
The relative code is this:
<ul class="page-menu">
<li class="page_item page-item-30">Maria Montessori</li>
<li class="page_item page-item-32">La pedagogia scientifica</li>
...
And the css:
.page-menu {
display: inline-block;
margin-right: 25px;
text-align: center;
width: 210px;
li {
margin-bottom: 10px;
}
li.current_page_item {
a {
background-color: $blue-montessori;
border-bottom: 2px solid $blue-montessori;
color: white;
font-weight: bold;
}
}
li.current_page_parent {
a {
background-color: $blue-montessori;
border-bottom: 2px solid $blue-montessori;
color: white;
font-weight: bold;
}
}
a {
background-color: $grey-light;
border-bottom: 2px solid $grey-light;
color: $grey-dark;
display: block;
font-family: Lato;
font-weight: 300;
line-height: 1.2;
padding: 15px 20px;
text-decoration: none;
text-transform: uppercase;
&:hover {
background-color: $blue-light;
border-bottom: 2px solid $blue-dark;
color: white;
font-weight: 400;
}
}
ul.children {
margin-top: 10px;
li {
margin-bottom: 10px;
margin-left: 10px;
}
li a {
background-color: #f9f9f9;
border-bottom: 2px solid #f9f9f9;
color: $grey-dark;
display: block;
font-family: Lato;
font-size: 12px;
font-weight: 400;
line-height: 1.2;
padding: 10px 20px;
text-decoration: none;
text-transform: uppercase;
&:hover {
background-color: $blue-light;
border-bottom: 2px solid $blue-dark;
color: white;
font-weight: 400;
}
}
li.current_page_item {
a {
background-color: $blue-montessori;
border-bottom: 2px solid $blue-montessori;
color: white;
font-weight: bold;
}
}
}
.page_item_has_children > .children {display: none;} /*hides the submenu*/
.page_item_has_children.current_page_item > .children,
.page_item_has_children.current_page_ancestor > .children {display: block;} /*shows the submenu for the current page or when on its subpages */
}
Inspecting it with developer tools didn't really help and what's strange is that the issue appears to be only on the first element. And in Firefox works fine, anyway.
Your div menu-menu-1-container is overlapping to your first menu because of line height property of your div .nav-menu use padding instead
.nav-menu {
padding: 17px; /* remove line-height property */
}
Updated working Code
IE only knows how to make smokers who've just quite, smoke again!!
I'm trying to perfect this responsive Navigational Menu (as well as another website I've developed) to RESPOND with IE8 (i'm not sure what the NAV looks like in www.testing123.co.za/test1.htm
when I re-size the my browser window, it seems like the NAV is ignoring my media queries OR IE8 is not liking the float involved in this design. I seem to think it's the latter.
I've done some research and have hear that this should be included in your page for the media queries to be applied, but I still have no luck when including the js file. I'm not sure what I've probably done wrong here?
I included the js file like so:
<script src="css3-mediaqueries.js"></script>
Anyway, I'd appreciate some clarification at what must be done to correct IE 8 Float problems (assuming this is the issue).
Appreciate your help, thanks
CSS goes like:
nav {
width: 90%;
margin: 0px auto;
}
nav ul {
list-style: none;
overflow: hidden;
}
nav li a {
background: #444;
border-right: 1px solid #fff;
color: #fff;
display: block;
float: left;
font: 100 24px/1.4 TrumpGothicWestRegular;
padding: 10px;
text-align: center;
text-decoration: none;
text-transform: uppercase;
width: 12.5%;
min-height:80px;
padding-top:60px;
}
nav li a img { padding-bottom:5px; display:block; margin: 0px auto; }
/*SMALL*/
nav small {
color: #aaa;
font: 100 11px/1 Helvetica, Verdana, Arial, sans-serif;
text-transform: none;
}
nav li a:hover {
background: #222;
}
nav li:last-child a {
border: none;
}
Viewports under 1100px (small-device1100.css):
nav li a {
font: 100 21px/1.4 TrumpGothicWestRegular;
min-height:inherit;
padding: 10px;
}
nav small {
font: 100 8px/1 Helvetica, Verdana, Arial, sans-serif;
}
nav li a img { display:none; }
Viewports under 825px (small-device825.css):
nav li a {
width: 33.333333333333333333333333333333%;
border-bottom: 1px solid #fff;
font: 100 24px/1.4 TrumpGothicWestRegular;
}
nav li:last-child a, nav li:nth-child(3) a {
border-right: none;
}
nav li:nth-child(4) a, nav li:nth-child(5) a, nav li:nth-child(6) a {
border-bottom: none;
}
Viewports under 350px (small-device350.css):
nav li a {
width: 50%;
font: 400 21px/1.4 TrumpGothicWestRegular;
padding-top: 12px;
padding-bottom: 12px;
}
nav li:nth-child(even) a {
border-right: none;
}
nav li:nth-child(3) a {
border-right: 1px solid #fff;
}
nav li:nth-child(4) a, nav li:nth-child(5) a {
border-bottom: 1px solid #fff;
}
I have a menu that needs a dotted border on hover, is it possible to stop it nudging the list items to the right on hover?
http://jsfiddle.net/mkTvp/
It will be in a CMS so I can't set a width on the LI's
Give the items 2px transparent borders: http://jsfiddle.net/mkTvp/1/
Just add a border to the original style the same color as the background:
li {
display: block;
float: left;
padding: 3px;
border: 2px solid #fff; /*same as background color*/
}
Example here.
a {
background-color: #F78F1E;
color: #fff;
display: block;
font-family: helvetica, sans-serif;
font-size: 0.688em;
font-weight: bold;
padding: 12px 12px;
text-decoration: none;
text-transform: uppercase;
width: auto;
}
li {
display: block;
float: left;
padding: 1px;
border: 2px solid white; /** Same as background-color */
}
li:hover { border: 2px dashed #F78F1E;}