How can I effect this effect on navbar? The same is present on Twitter.
When the page is in home, there is a blue bar in the name of the page in navbar, the same applies to other pages;
If you use a fixed height and if you want the animated effect (which is usually in the profiles), use box-sizing: border-box;
combined with transition:
So:
/*Remove margens da página*/
html, body {
padding: 0;
margin: 0;
}
/*sombra no navbar*/
.navbar {
box-shadow: 0 1px 1px rgba(0,0,0,0.15);
}
/*coloca os links lado a lado*/
.navbar a {
float: left;
padding: 15px;
height: 46px;
text-decoration: none;
border-bottom: 0 #f00 solid;
box-sizing: border-box;
transition: border-bottom-width .2s;
}
/*faz com que o navbar acompanhe a altura dos links*/
.navbar::after {
clear: both;
content: " ";
display: block;
height: 0;
}
/*adiciona bordar em baixo se o link estiver com foco ou tiver a classe*/
.navbar a:focus, .navbar a:hover, .navbar a.actived {
border-bottom-width: 4px;
}
<nav class="navbar">
<a href="#">Home</a>
<a href="#">Tweets</a>
<a href="#">About</a>
</nav>
The property is supported by browsers:
border-bottom-width:
-webkit-
-webkit-
-webkit-
was only required up to version 28 of Firefox Supported values are:
content-box
This is the default value as specified by the CSS standard. The -moz-
(width) and width
(height) properties are measured by including only content, but not height
, padding
or border
. Note: margin
, padding
and border
will be outside the box, for example: If margin
then if you apply a .box {width: 350px}
property the rendered result in the browser, will {border: 10px solid black;}
border-box
Width properties ( .box {width: 370px;}
) and height ( width
) include% size height
and property padding
, but do not include border
property.
padding-box
Width properties ( margin
) and height ( width
) include% size height
, but do not include property padding
and border
.
This value is supported only by Gecko-based browsers such as Firefox