How to let underline fade in beneath link on hover? - html

How can I fade in an underline on hover over a link like in the video below?
I found this CSS by using the developer console, but I can't figure out how it works.
.mainContent p>a:hover::after, .mainContent li>a:hover::after, .mainContent .text a:hover::after, .mainContent p>a:focus::after, .mainContent li>a:focus::after, .mainContent .text a:focus::after {
opacity: 1;
-webkit-transform: translateY(-2px);
-moz-transform: translateY(-2px);
transform: translateY(-2px);
}
.mainContent p>a::after, .mainContent li>a::after, .mainContent .text a::after {
position: absolute;
top: 100%;
left: 0;
width: 100%;
height: 1px;
background: rgba(226,0,26,1);
content: '';
opacity: 0;
-webkit-transition: opacity 0.15s,-webkit-transform 0.2s;
-moz-transition: opacity 0.15s,-moz-transform 0.2s;
transition: opacity 0.15s,transform 0.2s;
-webkit-transform: translateY(4px);
-moz-transform: translateY(4px);
transform: translateY(4px);
}
HTML
Hallenplan
How does this work and is there a even better way?

To do this effect you need two things:
Give the a a position attribute
Animate its after element by placing it at the bottom through position: absolute and then transforming it.
One possible way is:
a {
position: relative;
text-decoration: none;
}
a:hover::after, a:focus::after {
opacity: 1;
transform: translateY(-2px);
}
a::after {
position: absolute;
top: 100%;
left: 0;
width: 100%;
height: 1px;
background: black;
content: '';
opacity: 0;
transition: opacity 0.2s, transform 0.2s;
transform: translateY(4px);
}
<a href="http://www.stackoverflow.com">
StackOverflow
</a>

Related

The page shows hidden items off the screen in mobile mode

I trying to resolve it, but i dont know that problems is with menu, or icon of chat(using tawk.to)
The page is also online on www.niebieskiczat.pl
I never had this problem, but i think i change something and now i got this like that, or maybe tawk.to change somethink? The hamburger menu should appear on the regular website and on the mobile. Now on PC working god, but on mobile i got problem like on picture. Here is code for CSS navbar
.menuToggle {
display: block;
position: absolute;
top: 40px;
right: 120px;
z-index: 1;
-webkit-user-select: none;
user-select: none;
}
.menuToggle input {
display: block;
width: 40px;
height: 32px;
position: absolute;
top: -7px;
left: -5px;
cursor: pointer;
opacity: 0;
z-index: 2;
-webkit-touch-callout: none;
}
.menuToggle span {
display: block;
width: 33px;
height: 4px;
margin-bottom: 5px;
position: relative;
background: #cdcdcd;
border-radius: 3px;
z-index: 1;
transform-origin: 4px 0px;
transition: transform 0.5s cubic-bezier(0.77, 0.2, 0.05, 1),
background 0.5s cubic-bezier(0.77, 0.2, 0.05, 1), opacity 0.55s ease;
}
.menuToggle span:first-child {
transform-origin: 0% 0%;
}
.menuToggle span:nth-last-child(2) {
transform-origin: 0% 100%;
}
.menuToggle input:checked ~ span {
opacity: 1;
transform: rotate(45deg) translate(-2px, -1px);
background: #232323;
}
.menuToggle input:checked ~ span:nth-last-child(3) {
opacity: 0;
transform: rotate(0deg) scale(0.2, 0.2);
}
.menuToggle input:checked ~ span:nth-last-child(2) {
opacity: 1;
transform: rotate(-45deg) translate(0, -1px);
}
.menu {
position: absolute;
width: 300px;
margin: -80px 0 0 0;
padding: 50px;
padding-top: 105px;
right: -150px;
background: lightblue;
list-style-type: none;
-webkit-font-smoothing: antialiased;
transform-origin: 0% 0%;
transform: translate(100%, 0);
transition: transform 0.5s cubic-bezier(0.77, 0.2, 0.05, 1);
}
.menu li {
padding: 10px 0;
font-size: 1.2em;
}
.menuToggle input:checked ~ ul {
transform: none;
opacity: 1;
}
#media screen and (max-width: 768px) {
#menu {
transform: none;
opacity: 0;
transition: opacity 0.5s cubic-bezier(0.77, 0.2, 0.05, 1);
}
}
And HTML
<nav role='navigation'>
<div class="menuToggle">
<input type="checkbox" />
<span></span>
<span></span>
<span></span>
<ul class="menu">
<a href="pages/about.html">
<li>O nas</li>
</a>
<a href="pages/howtotalk.html">
<li>Jak rozmawiać?</li>
</a>
<a href="pages/contacts.html">
<li>Przydatne kontakty</li>
</a>
</ul>
</div>
</nav>
Add this to your menu class.
It will solve your problem.
.menu {
position: fixed;
right: 0;
}
try
#media and screen and (max-width:766px){ .menu{ display:none; } }

Animated link underline doesn't work with vertical text

I tried to use this guide to animate my links' undeline.
However, for the vertical text it doesn't really work, see my Codepen here
What can I change (if possible) to have the vertical text underlined properly with this animation?
HTML:
<div class="hlinks">
ABOUT —
CONTACT
</div>
CSS:
.hlinks {
writing-mode: vertical-rl;
position: fixed;
right: 20%;
top: 20px;
display: inline;
}
a {
position: relative;
color: #000;
text-decoration: none;
}
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;
}
a:hover:before {
visibility: visible;
-webkit-transform: scaleX(1);
transform: scaleX(1);
}
Again, here's my sample: https://codepen.io/alanvkarlik/pen/QmJQev
You need to adjust your CSS for the .hlinks a elements so that they behave slightly differently from the regular a elements, especially in position of underline and scaling along a different axis.
.hlinks {
writing-mode: vertical-rl;
position: fixed;
right: 20%;
top: 20px;
display: inline;
}
a {
position: relative;
color: #000;
text-decoration: none;
}
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;
}
.hlinks a:before {
content: "";
position: absolute;
height: 100%;
width: 1px;
top: 0;
left: 0;
background-color: #000;
visibility: hidden;
-webkit-transform: scaleY(0);
transform: scaleY(0);
-webkit-transition: all 0.3s ease-in-out 0s;
transition: all 0.3s ease-in-out 0s;
}
a:hover:before {
visibility: visible;
-webkit-transform: scaleX(1);
transform: scaleX(1);
}
.hlinks a:hover:before {
visibility: visible;
-webkit-transform: scaleY(1);
transform: scaleY(1);
}
<div class="hlinks">
ABOUT —
CONTACT
</div>
ABOUT —
CONTACT
You just need to make some adjustments in positioning of the pseudo-element and a few minor stylistic changes.
.hlinks {
writing-mode: vertical-rl;
position: fixed;
right: 20%;
top: 20px;
display: inline;
}
a {
position: relative;
color: #000;
text-decoration: none;
}
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;
}
a:hover:before {
visibility: visible;
-webkit-transform: scaleX(1);
transform: scaleX(1);
}
.hlinks a::before {
width: 1px;
height: 0;
top: 0;
}
.hlinks a:hover:before {
visibility: visible;
height: 100%;
<div class="hlinks">
ABOUT —
CONTACT
</div>
ABOUT —
CONTACT
You just need to flip your axis since your text is vertical instead of horizontal. Change all instances of "scaleX" to "scaleY", and then then flip the height and width on a:before. That should do it.

Calculating Pseudo-elements as Part of Element's Width

Right now I have a button with ::before and ::after pseudo-elements that is set to a 90% of the width of its parent div. However, I can't seem to get the pseudo-elements to be calculated in this 90%. Essentially, what I want is the border-box CSS rule but with pseudo-elements. Here's my code:
HTML
<button type"submit">Send</button>
CSS
.contact button {
height: 60px;
background-color: #fff;
font-weight: bold;
position: relative;
cursor: pointer;
}
.contact button::after,
.contact button::before {
content: "";
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
border: 3px solid #333;
-webkit-transition: -webkit-transform 0.2s;
transition: -webkit-transform 0.2s;
transition: transform 0.2s;
transition: transform 0.2s, -webkit-transform 0.2s;
}
.contact button::after {
-webkit-transform: translate(3px, 3px);
transform: translate(3px, 3px);
}
.contact button::before {
-webkit-transform: translate(-3px, -3px);
transform: translate(-3px, -3px);
}
Here's a link to my codepen: http://codepen.io/Hudson_Taylor11/pen/XpBMwM?editors=1100
Thanks!
The easiest fix I found was this:
left: 3px;
right: 3px;
For both pseudo-elements.

How can I create two id tags from this script?

I want to make it so that I can have multiple buttons opening their own transition. As of now I have this code which works fine, however, if I repeat it or even change the css (class) to match an individual button, the primary button will still open the secondary transition and the newly placed secondary button remains inactive.
CSS
<style>
body,
.container,
.content-wrap {
overflow: hidden;
width: 100%;
height: 100%;
}
.container {
background: #fff;
}
.menu-wrap a {
color: #b8b7ad;
}
.menu-wrap a:hover,
.menu-wrap a:focus {
color: #c94e50;
}
.content-wrap {
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
}
.content {
position: absolute;
background: #fff;
overflow-y: visible;
}
.content::before {
position: absolute;
top: 0;
left: 0;
z-index: 10;
width: 100%;
height: 100%;
background: none;
content: '';
opacity: 0;
-webkit-transform: translate3d(100%,0,0);
transform: translate3d(100%,0,0);
-webkit-transition: opacity 0.4s, -webkit-transform 0s 0.4s;
transition: opacity 0.4s, transform 0s 0.4s;
-webkit-transition-timing-function: cubic-bezier(0.7,0,0.3,1);
transition-timing-function: cubic-bezier(0.7,0,0.3,1);
}
/* Menu Button 1 */
.menu-button {
position: absolute;
z-index: 1000;
margin: 1em;
padding: 0;
width: 10px;
height: 50px;
border: none;
text-indent: 2.5em;
font-size: 1.5em;
color: transparent;
background: transparent;
opacity: 1;
top: 510px;
left: 855px;
-ms-transform: rotate(7deg); /* IE 9 */ -webkit-transform: rotate(7deg); /* Chrome, Safari, Opera */
transform: rotate(90deg);
}
.menu-button::before {
position: absolute;
top: 0.5em;
right: 0.2em;
bottom: 0.4em;
left: -1px;
background: linear-gradient(#929292 20%, transparent 20%, transparent 40%, #929292 40%, #929292 58%, transparent 0%, transparent 80%, #929292 80%);
content: '';
}
.menu-button:hover {
opacity: 1;
}
/* Close Button */
.close-button {
width: 50px;
height: 50px;
position: absolute;
right: 1em;
top: 1em;
overflow: hidden;
text-indent: 1em;
font-size: 0.75em;
border: none;
background: transparent;
color: transparent;
opacity: 0;
}
.close-button::before,
.close-button::after {
content: '';
position: absolute;
width: 3px;
height: 100%;
top: 0;
left: 50%;
background: #bdc3c7;
}
.close-button::before {
-webkit-transform: rotate(45deg);
transform: rotate(45deg);
}
.close-button::after {
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
}
/* Comments */
.menu-wrap {
position: absolute;
z-index: 1000;
width: 429.0500011444092px;
height: 600.875px;
right: 0;
background: #0C0C0C;
top: 6px;
padding: 0;
font-size: 1.15em;
-webkit-transform: translate3d(500px,0,0);
transform: translate3d(500px,0,0);
-webkit-transition: -webkit-transform 0.4s;
transition: transform 0.4s;
-webkit-transition-timing-function: cubic-bezier(0.7,0,0.3,1);
transition-timing-function: cubic-bezier(0.7,0,0.3,1);
}
.menu,
.icon-list {
height: 100%;
}
.icon-list {
-webkit-transform: translate3d(0,100%,0);
transform: translate3d(0,100%,0);
}
.icon-list a {
display: block;
padding: 0.8em;
-webkit-transform: translate3d(0,500px,0);
transform: translate3d(0,500px,0);
}
.icon-list,
.icon-list a {
-webkit-transition: -webkit-transform 0s 0.4s;
transition: transform 0s 0.4s;
-webkit-transition-timing-function: cubic-bezier(0.7,0,0.3,1);
transition-timing-function: cubic-bezier(0.7,0,0.3,1);
}
.icon-list a:nth-child(2) {
-webkit-transform: translate3d(0,1000px,0);
transform: translate3d(0,1000px,0);
}
.icon-list a:nth-child(3) {
-webkit-transform: translate3d(0,1500px,0);
transform: translate3d(0,1500px,0);
}
.icon-list a:nth-child(4) {
-webkit-transform: translate3d(0,2000px,0);
transform: translate3d(0,2000px,0);
}
.icon-list a:nth-child(5) {
-webkit-transform: translate3d(0,2500px,0);
transform: translate3d(0,2500px,0);
}
.icon-list a:nth-child(6) {
-webkit-transform: translate3d(0,3000px,0);
transform: translate3d(0,3000px,0);
}
.icon-list a span {
margin-left: 10px;
font-weight: 700;
}
/* Shown menu */
.show-menu .menu-wrap {
-webkit-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
-webkit-transition: -webkit-transform 0.8s;
transition: transform 0.8s;
-webkit-transition-timing-function: cubic-bezier(0.7,0,0.3,1);
transition-timing-function: cubic-bezier(0.7,0,0.3,1);
}
.show-menu .icon-list,
.show-menu .icon-list a {
-webkit-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
-webkit-transition: -webkit-transform 0.8s;
transition: transform 0.8s;
-webkit-transition-timing-function: cubic-bezier(0.7,0,0.3,1);
transition-timing-function: cubic-bezier(0.7,0,0.3,1);
}
.show-menu .icon-list a {
-webkit-transition-duration: 0.9s;
transition-duration: 0.9s;
}
.show-menu .content::before {
opacity: 1;
-webkit-transition: opacity 0.8s;
transition: opacity 0.8s;
-webkit-transition-timing-function: cubic-bezier(0.7,0,0.3,1);
transition-timing-function: cubic-bezier(0.7,0,0.3,1);
-webkit-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
}</style>
BEING TRANSITIONED
<div class="menu-wrap">
</div>
BUTTON
<button class="menu-button" id="open-button">Open Menu</button>
DEMO
DEMO
As you can see if you scroll towards the middle of the demo result window you will see the first button opening both transitions while the second button does nothing, I want the second button to open the bottom transition on its own.

Firefox very ugly jittered blurred css3 transition (animation)

Currently i am creating a website and i want to use the "new" css3 animations. It is hard to described what i've done, so i made a small example with the problem. When you hover with the mouse over the block the animation in firefox is very ugly. Furthermore the background image jitters 1px. The font gets blurry and the logo too. In IE11, Chrome its all working very fine :)
Here is the link: https://jsfiddle.net/0gk3fhnv/ or full code:
<ul id="parallelogram-box">
<li class="parallelogram">
<div class="text">Very nice descr Text! And here sec Row...</div>
<div class="logo"></div>
</li>
</ul>
.
body {
background: #eee;
}
#parallelogram-box {
list-style-type: none;
margin-left: 0px;
padding-left: 0px;
text-align: center;
}
#parallelogram-box li {
text-align: left;
position: relative;
list-style-type: none;
display: inline-block;
min-height: 400px;
min-width: 200px;
max-width: 200px;
transform: skew(-15deg);
-o-transform: skew(-15deg);
-webkit-transform: skew(-15deg);
margin: 20px;
overflow: hidden;
border-radius: 5%;
backface-visibility: hidden;
}
#parallelogram-box li:hover .text {
bottom: 0px;
transition: bottom 0.2s ease-in 0s;
-webkit-transition: bottom 0.2s ease-in 0s;
-moz-transition: bottom 0.2s ease-in 0s;
-o-transition: bottom 0.2s ease-in 0s;
}
#parallelogram-box li:hover {
transform: skew(-15deg);
-o-transform: skew(-15deg);
-webkit-transform: skew(-15deg);
}
#parallelogram-box li:before {
content: "";
position: absolute;
width:200%;
height:200%;
z-index: -1;
transform: skew(15deg) translateZ(0) scale(1.0, 1.0) translate3d(0,0,0);
-o-transform: skew(15deg) translateZ(0) scale(1.0, 1.0) translate3d(0,0,0);
-webkit-transform: skew(15deg) translateZ(0) scale(1.0, 1.0) translate3d(0,0,0);
}
li.parallelogram:before {
background: url(http://i65.photobucket.com/albums/h235/Ignwar/Album%20Mountains/AlaskanMonoliths.jpg);
background-position: -1000px -200px;
}
#parallelogram-box p {
font-size: 20px;
text-align: center;
}
#parallelogram-box li > * {
transform: skew(15deg) translateZ(0) scale(1.0, 1.0) translate3d(0,0,0);
-o-transform: skew(15deg) translateZ(0) scale(1.0, 1.0) translate3d(0,0,0);
-webkit-transform: skew(15deg) translateZ(0) scale(1.0, 1.0) translate3d(0,0,0);
}
.text {
background: rgba(36,36,36,.9);
color: #e9e9e9;
position: absolute;
bottom: -75px;
height: 100px;
width: 180px;
z-index: 1;
font-size: 14pt;
margin-left: -12px;
text-align: center;
padding: 10px 25px 10px 25px;
transition: bottom 0.1s ease-in 0s;
-webkit-transition: bottom 0.1s ease-in 0s;
-moz-transition: bottom 0.1s ease-in 0s;
-o-transition: bottom 0.1s ease-in 0s;
-webkit-transform: translate3d(0,0,0);
transform: translate3d(0,0,0);
}
.logo {
position: absolute;
top: 50%;
margin-top: -100px;
width: 200px;
height: 200px;
}
.parallelogram .logo {
background: url(http://www.findthatlogo.com/wp-content/uploads/2011/10/dallas-mavericks-logo.png) no-repeat;
background-size: contain;
background-position: 50% 50%;
}
Can you please tell me, whats causing this strange behavior? Is there a work around?
I've found a solution!
Look at https://jsfiddle.net/0gk3fhnv/5/
#-moz-document url-prefix() {
#parallelogram-box li:after {
content: "";
position: absolute;
width:200%;
height:200%;
z-index: -1;
transform: none !important;
}
li.parallelogram:after {
background-image: url(for_firefox_skewed_picure.png);
}
}
I changed the transition duration for firefox to 0.01 seconds and a linear animation to obscure the blurry text. Furthermore i added the css code above, which adds a exception for Firefox. The code removes the skew of the background image. So you have to add a custom background image for Firefox and skew it for your % in Photoshop or another photo editing software.