I want to make the sliding underline to run from left to right when i hover, and also set up the width of the line from the 1st letter to the last, and not bigger. How can i do that?
.nav-bar a:hover {
color: #000;
}
.nav-bar a:before {
content: "";
position: absolute;
width: 100%;
height: 1px;
bottom: 0;
left: 0;
background-color: #000;
visibility: hidden;
-webkit-transform: scaleX(0);
transform: scaleX(0);
-webkit-transition: all 0.3s ease-in-out 0s;
transition: all 0.3s ease-in-out 0s;
}
.nav-bar a:hover:before {
visibility: visible;
-webkit-transform: scaleX(1);
transform: scaleX(1);
}
<div class="nav-bar">
<ul>
<li>RETROSPECTIVE SHOW /2006/</li>
<li>TEXTS</li>
<li>BIBLOGRAPHY</li>
</ul>
</div>
You can use display: inline-block; to keep the fixed width. And for underlining you can use pseudo-classes like :before and :after.
Have a look at the snippet below:
/* LEFT TO RIGHT */
.sliding-left-to-right {
display: inline-block;
margin: 0;
}
.sliding-left-to-right:after {
content: '';
display: block;
height: 3px;
width: 0;
background: transparent;
transition: width .5s ease, background-color .5s ease;
}
.sliding-left-to-right:hover:after {
width: 100%;
background: blue;
}
/* LAYOUT STYLING */
body {
margin: 20px;
}
a {
text-decoration: none;
font-size: 20px;
font-weight: bold;
color: blue;
}
a:hover {
color: blue;
text-decoration: none;
cursor: pointer;
}
<a class="sliding-left-to-right">Underline – Left to Right</a>
Hope this helps!
I am trying to increase the hit area of the link in the menu but doing so also increases the underline effect of the text. I have tried padding and width but no imrprovement. I want a effect just like the one present in highfive mobile menu(Underline from left). Here is the fiddle and Here is the code
.hvr-underline-from-left {
text-decoration:none;
padding: 3px 0;
color: #000;
cursor: pointer;
display: inline-block;
vertical-align: middle;
-webkit-transform: translateZ(0);
transform: translateZ(0);
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-moz-osx-font-smoothing: grayscale;
position: relative;
overflow: hidden;
}
.hvr-underline-from-left:before {
content: "";
position: absolute;
z-index: -1;
left: 0;
right: 100%;
bottom : 7px;
background: #E13F3F;
height: 2px;
-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;
}
.hvr-underline-from-left:hover:before, .hvr-underline-from-left:focus:before, .hvr-underline-from-left:active:before {
right: 0;
}
<html>
<body>
<a class="hvr-underline-from-left" href="#">About </a>
</body>
</html>
You could add a span within the a-tag and put the underline effect on the span instead.
This way you can add padding to your link element without it affecting the underline effect.
a {
padding: 20px;
display: inline-block;
background: #eee;
}
.hvr-underline-from-left {
text-decoration: none;
padding: 3px 0;
color: #000;
cursor: pointer;
display: inline-block;
vertical-align: middle;
-webkit-transform: translateZ(0);
transform: translateZ(0);
box-shadow: 0 0 1px rgba(0, 0, 0, 0);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-moz-osx-font-smoothing: grayscale;
position: relative;
overflow: hidden;
}
.hvr-underline-from-left:before {
content: "";
position: absolute;
z-index: -1;
left: 0;
right: 100%;
bottom: 7px;
background: #E13F3F;
height: 2px;
-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;
}
a:hover .hvr-underline-from-left:before,
.hvr-underline-from-left:focus:before,
.hvr-underline-from-left:active:before {
right: 0;
}
<html>
<body>
<span class="hvr-underline-from-left">About</span>
</body>
</html>
I'm trying to implement a menu nav bar that on hover highlights the menu item with an underline animation from LEFT to RIGHT.
Currently I have the underline animating from the center of the menu item to the outside.
I have tried searchng for a solution to this but can't figure out what I'm doing wrong.
Here is a link to the project on codepen http://codepen.io/anon/pen/JowgqP
HTML
<menu>
<p><strong>Home</strong>
<strong>About</strong>
<strong>Portfolio</strong>
<strong>Contact</strong> <strong>
<p class="note">This is a recreation of the link hover effect from factmag.com</small>
</menu>
CSS (SCSS)
#import url(http://fonts.googleapis.com/css?family=Noto+Serif:400,700,400italic);
$link-color: #E71818;
$text-color: black;
$article-font: Noto serif, serif;
menu {
color: $text-color;
font-family: $article-font;
max-width: 30em;
}
p {
font-size: 18px;
line-height: 1.5;
}
menu a {
#extend %fancy-link;
}
.note {
display: inline-block;
border-top: 1px solid $link-color;
color: #777;
font-size: .8em;
font-style: italic;
margin-top: 2em;
padding-top: 1em;
}
%fancy-link {
color: $link-color;
position: relative;
text-decoration: none;
transition: all 0.15s ease-out;
&:before {
content: "";
position: absolute;
width: 100%;
height: 1px;
bottom: 0px;
left: 0;
background: #f00;
visibility: hidden;
transform: scaleX(0);
transition: all 0.3s ease-in-out 0s;
}
&:hover {
transition: all 0.15s ease-out;
&:before {
visibility: visible;
transform: scaleX(1);
}
}
}
The default transformation point is center center...or rather 50% 50% for ease of reference. (For 2 dimensions...we'll leave out z offsets for now.)
You would have to amend this so that the origin is now center left
&:before {
content: "";
position: absolute;
width: 100%;
height: 1px;
bottom: 0px;
left: 0;
background: #f00;
visibility: hidden;
transform: scaleX(0);
transform-origin: center left; /* here */
transition: all 0.3s ease-in-out 0s;
}
Codepen Demo
Transform-Origin # MDN
I want it so that when I hover over the image the text appears the same way I have it except its opacity is unchanged.
example: http://jsfiddle.net/guineapig101/UEtLJ/
html:
<a class="img1"><p class="hoverText">yoooo</p></a>
css:
html,body{
width: 100%;
height: 100%;
background-color: #000;
}
p{
color: #fff;
font-size: 16px;
font-family: arial, arial black, italic;
}
.hoverText{
text-align: center;
visibility: hidden;
position: relative;
}
.img1{
position: absolute;
background-image: url('http://animalscamp.com/wp-content/uploads/2011/12/Grizzly-Bear- 3.jpg');
top: 0px;
left:0px;
width: 30%;
height: 40%;
}
.img1:hover p{
visibility: visible;
z-index: 9000;
}
.img1:hover{
cursor: pointer;
opacity: 0.6;
-webkit-transition: opacity;
-webkit-transition-property: opacity;
-webkit-transition-duration: 500ms;
-webkit-transition-timing-function: ease-out;
-webkit-transition-delay: initial;
-webkit-transition-timing-function: ease-out;
-webkit-transition-duration: 500ms;
}
You cannot affect the opacity of a background image..you would normally have to use an actual image in the HTML but rather than an an unsemantic extra element purely for styling purposes you can manage this with a pseudo element like so.
JSfiddle
CSS
html,body{
width: 100%;
height: 100%;
background-color: #000;
}
p{
color: #fff;
font-size: 16px;
font-family: arial, arial black, italic;
}
.hoverText{
text-align: center;
visibility: hidden;
position: relative;
}
.img1:hover .hoverText{
visibility: visible;
cursor: pointer;
}
.img1{
position: absolute;
top: 0px;
left:0px;
width: 30%;
height: 40%;
}
.img1:before {
content:"";
position: absolute;
top:0;
left:0;
height:100%;
width:100%;
background-image: url('http://animalscamp.com/wp-content/uploads/2011/12/Grizzly-Bear-3.jpg');
transition:opacity.5s ease;
}
.img1:hover:before {
opacity:0.6;
}
You would need another element to put the image in, so that the text is not inside the element that you set the opacity on:
HTML:
<a class="img1"><span></span><p class="hoverText">yoooo</p></a>
CSS:
html,body{
width: 100%;
height: 100%;
background-color: #000;
}
p{
color: #fff;
font-size: 16px;
font-family: arial, arial black, italic;
}
.hoverText{
text-align: center;
visibility: hidden;
position: relative;
}
.img1{
position: absolute;
top: 0px;
left:0px;
width: 30%;
height: 40%;
cursor: pointer;
}
.img1 span {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-image: url('http://animalscamp.com/wp-content/uploads/2011/12/Grizzly-Bear-3.jpg');
}
.img1:hover p{
visibility: visible;
z-index: 9000;
}
.img1:hover{
-webkit-transition: opacity;
-webkit-transition-property: opacity;
-webkit-transition-duration: 500ms;
-webkit-transition-timing-function: ease-out;
-webkit-transition-delay: initial;
-webkit-transition-timing-function: ease-out;
-webkit-transition-duration: 500ms;
}
.img1:hover span {
opacity: 0.6;
}
Demo: http://jsfiddle.net/UEtLJ/3/
For some reason, one of the sections of my page becomes the last section of my page despite having more sections below it in the HTML document. If the section is removed the other sections are shown. Is there something in the HTMl or CSS that affected my page? I need the rest of the page to be shown because it contains important information.
The HTML:
<!-- ===========================================================================
START NATURAL LANGUAGE MARKUP
=========================================================================== -->
<section id="nlmarkup">
<div class="inner">
<h2>Who I am. <i class="title_line"></i> </h2>
<p class="lead">The most important thing to me is
<br>building products people love.</p>
<form id="nl-form" class="nl-form">"I feel like making a
<select>
<option value="1" selected>app</option>
<option value="2">website</option>
<option value="3">mockup</option>
</select>
<br />that is
<input type="text" value="" placeholder="(adjective)" data-subline="For example: <em>Responsive</em> or <em>Cool</em>"
/>within
<br />the next
<select>
<option value="1" selected>week</option>
<option value="1">two weeks</option>
<option value="2">month</option>
<option value="3">six months</option>
<option vlaue="4">year</option>
</select>and
<br>delivered to me via
<select>
<option value="1" selected>email</option>
<option value="1">dribbble</option>
<option value="2">behance</option>
</select>."
<div class="nl-overlay"></div>
</form>
</div>
</div>
</section>
The CSS:
#font-face {
font-family: 'nlicons';
src:url('../fonts/nlicons/nlicons.eot');
src:url('../fonts/nlicons/nlicons.eot?#iefix') format('embedded-opentype'),
url('../fonts/nlicons/nlicons.woff') format('woff'),
url('../fonts/nlicons/nlicons.ttf') format('truetype'),
url('../fonts/nlicons/nlicons.svg#nlicons') format('svg');
font-weight: normal;
font-style: normal;
}
/* general style for the form */
.nl-form {
width: 100%;
margin: 0.3em auto 0 auto;
font-size: 4em;
line-height: 1.5;
}
.nl-form ul {
list-style: none;
margin: 0;
padding: 0;
}
/* normalize the input elements, make them look like everything else */
.nl-form input,
.nl-form select,
.nl-form button {
border: none;
background: transparent;
font-family: inherit;
font-size: inherit;
color: inherit;
font-weight: inherit;
line-height: inherit;
display: inline-block;
padding: 0;
margin: 0;
-webkit-appearance: none;
-moz-appearance: none;
}
.nl-form input:focus {
outline: none;
}
/* custom field (drop-down, text element) styling */
.nl-field {
display: inline-block;
position: relative;
}
.nl-field.nl-field-open {
z-index: 10000;
}
/* the toggle is the visible part in the form */
.nl-field-toggle,
.nl-form input,
.nl-form select {
line-height: inherit;
display: inline-block;
color: #b14943;
cursor: pointer;
border-bottom: 1px dashed #b14943;
}
/* drop-down list / text element */
.nl-field ul {
position: absolute;
visibility: hidden;
background: #00aed7;
left: -0.5em;
top: 50%;
font-size: 80%;
opacity: 0;
-webkit-transform: translateY(-40%) scale(0.9);
-moz-transform: translateY(-40%) scale(0.9);
transform: translateY(-40%) scale(0.9);
-webkit-transition: visibility 0s 0.3s, opacity 0.3s, -webkit-transform 0.3s;
-moz-transition: visibility 0s 0.3s, opacity 0.3s, -moz-transform 0.3s;
transition: visibility 0s 0.3s, opacity 0.3s, transform 0.3s;
}
.nl-field.nl-field-open ul {
visibility: visible;
opacity: 1;
-webkit-transform: translateY(-50%) scale(1);
-moz-transform: translateY(-50%) scale(1);
transform: translateY(-50%) scale(1);
-webkit-transition: visibility 0s 0s, opacity 0.3s, -webkit-transform 0.3s;
-moz-transition: visibility 0s 0s, opacity 0.3s, -moz-transform 0.3s;
transition: visibility 0s 0s, opacity 0.3s, transform 0.3s;
}
.nl-field ul li {
color: #fff;
position: relative;
}
.nl-dd ul li {
padding: 0 1.5em 0 0.5em;
cursor: pointer;
white-space: nowrap;
}
.nl-dd ul li.nl-dd-checked {
color: #478982;
}
.no-touch .nl-dd ul li:hover {
background: rgba(0,0,0,0.05);
}
.no-touch .nl-dd ul li:hover:active {
color: #478982;
}
/* icons for some elements */
.nl-dd ul li.nl-dd-checked:before,
.nl-submit:before,
.nl-field-go:before {
font-family: 'nlicons';
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
-webkit-font-smoothing: antialiased;
}
.nl-dd ul li.nl-dd-checked:before {
content: "\e000";
position: absolute;
right: 1em;
font-size: 50%;
line-height: 3;
}
.nl-ti-text ul {
min-width: 8em;
}
.nl-ti-text ul li.nl-ti-input input {
width: 100%;
padding: 0.2em 2em 0.2em 0.5em;
border-bottom: none;
color: #fff;
}
.nl-form .nl-field-go {
position: absolute;
right: 0;
top: 0;
height: 100%;
cursor: pointer;
background: rgba(0,0,0,0.1);
width: 1.8em;
text-align: center;
color: transparent;
}
.nl-field-go:before {
content: "\e001";
font-size: 75%;
color: #fff;
width: 100%;
line-height: 2.5;
display: block;
}
/* custom placeholder color */
input::-webkit-input-placeholder {
color: rgba(255,255,255,0.8);
}
input:active::-webkit-input-placeholder ,
input:focus::-webkit-input-placeholder {
color: rgba(255,255,255,0.2);
}
input::-moz-placeholder {
color: rgba(255,255,255,0.8);
}
input:active::-moz-placeholder,
input:focus::-moz-placeholder {
color: rgba(255,255,255,0.2);
}
input:-ms-input-placeholder {
color: rgba(255,255,255,0.8);
}
input:active::-ms-input-placeholder ,
input:focus::-ms-input-placeholder {
color: rgba(255,255,255,0.2);
}
/* example field below text input */
.nl-ti-text ul li.nl-ti-example {
font-size: 40%;
font-style: italic;
font-weight: 400;
padding: 0.4em 1em;
color: rgba(0,0,0,0.2);
border-top: 1px dashed rgba(255,255,255,0.7);
}
.nl-ti-text ul li.nl-ti-example em {
color: #fff
}
/* submit button */
.nl-submit-wrap {
margin-top: 0.4em;
}
/* overlay becomes visible when a field is opened */
.nl-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.5);
opacity: 0;
z-index: 9999;
visibility: hidden;
-webkit-transition: visibility 0s 0.3s, opacity 0.3s;
-moz-transition: visibility 0s 0.3s, opacity 0.3s;
transition: visibility 0s 0.3s, opacity 0.3s;
}
.nl-field.nl-field-open ~ .nl-overlay {
opacity: 1;
visibility: visible;
-webkit-transition-delay: 0s;
-moz-transition-delay: 0s;
transition-delay: 0s;
}
#media screen and (max-width: 45em) {
.nl-form {
font-size: 3em;
}
}
#media screen and (max-width: 25em) {
.nl-form {
font-size: 2em;
}
}
An additional </div> towards the bottom which has no opening <div>.
You open a section but you close a div.
Any decent IDE / Text editor could warn you about it. It's time to get one or it will become a pain.