Hallo I am trying to create a button aligned to the right of the screen which leads to the next article.
Everything works as I want it, till the point when I add the css transition.
As you can see in the fiddle I have twice the exact same code, except that the blue bar does have a css transition property and the green bar does not have a transition.
I am using the 64bit version of chrome (45.0.2453.0 dev-m) and while in here the green bar works as supposed when hovered, the content from the blue bar with the transition does have some major alignment bug. It seems that the content of the containers pops out of the containers.
<nav class="nav-next">
<a href="link" class="link">
<div class="thumbnail">
<img width="100" height="100" src="http://travelwithoutplan.com/wp-content/uploads/DSC01985_Vibrance-100-200x200.jpg" class="attachment-100x100 wp-post-image" alt="DSC01985 Vibrance 100" />
</div>
<div class="headline">Travel Information for Liechtenstein</div>
</a>
</nav>
CSS (without transition it works - but with transition it causes an alignment bug)
/*
.nav-next {
-moz-transition: width .5s;
-o-transition: width .5s;
-webkit-transition: width .5s;
transition: width .5s;
}
*/
.nav-next {
background-color: lightblue;
overflow: hidden;
position: fixed;
top: 50px;
left: auto;
right: 0;
box-sizing: border-box;
width: 30px;
height: 120px;
}
.nav-next:hover {
width: 330px;
}
.nav-next .headline:after, .nav-next .link {
display: block;
border-top: 1px solid #8c8c8c;
}
.nav-next .link {
background: #fff;
height: 120px;
width: 300px;
box-sizing: border-box;
padding: 10px;
position: absolute;
right: 0;
top: 0;
margin-left: 30px;
margin-right: 30px;
border: 1px solid #8c8c8c;
border-right: none;
}
.nav-next:hover .link {
margin-left: 0;
}
.nav-next .link:before {
color: #262626;
left: auto;
right: -23px;
position: absolute;
top: 52px;
font-size: 16px;
font-size: 1rem;
content: "\e12e";
font-family: wp-svg-plugin-icon-set1!important;
}
.nav-next .thumbnail {
position: relative;
width: 100px;
float: left;
margin-left: 0;
margin-right: 5px;
}
.nav-next .headline {
color: #595959;
height: 100px;
overflow: hidden;
padding-right: 10px;
padding-top: 5px;
position: relative;
left: 4px;
right: 0;
font-size: 14px;
}
.nav-next .headline:after {
content: "Next Article";
position: absolute;
width: 100%;
bottom: 0;
padding-top: 5px;
text-align: right;
}
http://jsfiddle.net/64g0vzq1/4/
Here you can see how with Chrome 64bit-version (45.0.2453.0 dev-m) the aligment of the content from the hovered blue bar (with css transition) is wrong. The text disappears behind the image, the image positionig is wrong etc.
Below the content of the green bar (without css transition) is shown correctly.
Is this a css error or something? How can I fix it?
Many thanks in advance!
Related
I want to make a small button hover animation. the animation is like that:
a blue div which have the same width an height as the button comes from the bottom left of the button to cover it. The problem is that they have not the same height and width.
Here's the HTML and the css :
[![button{
box-sizing: border-box;
background-color: transparent;
border: none;
display: inline-block;
}
.button-wrapper {
position: relative;
overflow: hidden;
padding: 15px 30px;
font-family: 'Montserrat', sans-serif;
font-weight: bold;
font-size: 14px;
line-height: 20px;
border: solid 2px #2A5A8B;
border-radius: 6px;
text-decoration: none;
color: #2A5A8B;
cursor : pointer;
transition: all .5s;
z-index: 1;
}
.button-wrapper::after{
width: 100%;
height: 100%;
margin: auto;
position: absolute;
bottom: -100%;
right: -100%;
background-color: #2A5A8B;
transition: all .25s;
z-index: -1;
content: '';
}
.button-wrapper:hover{
color: white;
}
.button-wrapper:hover::after{
transform: translateX(-100%) translateY(-100%);
}
<button>
<div className='button-wrapper'>
{Login}
</div>
</button>
PS: it's working properly on firefox.
I am having the weirdest problem: I am working on a portfolio page with images that should link to the various projects. There are 6 of these in total. Each of the images has a button that should live on top of it. When the button is hovered on by the user, it changes color, the cursor changes, and a popup with a short description of the project opens. When the button is clicked, there is an event listener that redirects to the project's page.
The problem is that in 2 out of the 6 instances, the moment I position the buttons inside the image, the buttons lose all functionality (including the event listener). As far as I can tell the code governing these 2 instances is the same as the other 4 where there is no such problem.
code where it doesn't work:
HTML:
<div class="container" id="linkTwo">
<img src="assets/images/bonez2.jpg" alt="bonez" style="width:200px; height:200px;" class="linkpic" >
<div class="btn1"id="btn1">Bone's Beatz<span id="bonezPop"> */some text that pops up/* </span></div>
</div>
CSS:
#linkTwo {
position: absolute;
top: 100px;
left: 230px;
}
#linkTwo #btn1:hover {
background-color: black;
}
#btn1 {
position: absolute;
left:20px;
padding-left: 23px;
padding-right: 23px;
}
#btn1 #bonezPop {
visibility: hidden;
width: 250px;
background-color: #883043;
color: #aa9e9e;
text-align: center;
border-radius: 6px;
border-style: solid;
border-color: black;
border-width: 2px;
padding: 5px 0;
position: absolute;
z-index: 1;
}
#btn1:hover #bonezPop {
visibility: visible;
}
.container #btn1 {
position: absolute;
top: -2px;
left: 20px;
font-size: 16px;
padding-top: 10px;
padding-bottom: 10px;
padding-left: 53px;
padding-right: 53px;
border: none;
cursor: pointer;
border-radius: 5px;
}
code that DOES work:
HTML:
<div class="container" id="linkFive">
<img src="assets/images/weather.jpg" alt="weather app" style="width:200px;height:200px;" class="linkpic">
<div class="btn3" id="btn3">Weather App<span id="weatherPop"> */some text that pops up */</span></div>
</div>
CSS:
#linkFive {
position: absolute;
top:320px;
}
#btn3 #weatherPop {
visibility: hidden;
width: 250px;
background-color: #883043;
color: #aa9e9e;
text-align: center;
border-radius: 6px;
border-style: solid;
border-color: black;
border-width: 2px;
padding: 5px 0;
position: absolute;
z-index: 1;
}
#btn3:hover #weatherPop {
visibility: visible;
}
#btn3 {
padding-left: 53px;
padding-right: 53px;
}
.container .btn3 {
position: absolute;
top: -2px;
left: 20px;
font-size: 16px;
padding-top: 10px;
padding-bottom: 10px;
padding-left: 60px;
padding-right: 40px;
border: none;
cursor: pointer;
border-radius: 5px;
}
.container .btn3:hover {
background-color: black;
}
I realize this whole thing would have been done much more easily with WordPress or some such, but this is a class assignment that requires I do this with code.
Thanks!
Short gif of how the problem looks
Found the answer. It was a different CSS rule that was for some reason breaking it:
.container {
position: relative;
width: 50%;
}
commenting this out solved the problem.
I have a button with the text "Description" that in IE is not clickable. Well, actually the far right edge of it is clickable, but not the whole button and text content of the button. It works fine in modern browsers (Chrome, Firefox), but not in IE. I am using IE 11 for testing. What is causing this and how do I fix it?
I've tried to strip out as much as possible...
.vertical-button {
width: 1px;
height: 20px;
background: #000;
position: absolute;
right: -68px;
top: calc(50% - 10px);
display: flex;
flex-direction: column;
justify-content: center;
opacity: 0;
-webkit-transition: 0.8s;
-moz-transition: 0.8s;
-ms-transition: 0.8s;
-o-transition: 0.8s;
transition: 0.8s;
}
.vertical-button {
right: -100px;
}
.project--active .vertical-button {
opacity: 1;
}
.project__image,
.project__text {
position: relative;
width: 100%;
max-width: 408px;
margin: 20px auto;
margin-bottom: 0px;
}
.project__text {
height: 200px;
padding: 8px;
}
.project__image,
.project__text {
width: 280px;
height: 210px;
display: inline-block;
margin: 0 auto;
}
.project__text {
padding-top: 20px;
padding-left: 20px;
}
.project {
-webkit-column-count: 2;
-moz-column-count: 2;
column-count: 2;
padding: 18px;
margin: 30px auto;
width: 614px;
height: 246px;
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.3);
}
.project {
padding: 20px;
width: 740px;
height: 295px;
}
.l-wrapper {
position: relative;
width: 86%;
max-width: 1024px;
margin: 0 auto;
}
.l-wrapper {
width: 80%;
}
.l-clear::after,
.l-wrapper::after {
clear: both;
content: "";
display: block;
height: 0px;
visibility: hidden;
}
.l-section {
padding: 30px 0;
}
.l-section__bg {
background-color: #F2F2F2;
}
.l-container {
position: relative;
padding-bottom: 50px;
overflow: hidden;
background-color: #FFFFFF;
z-index: 99;
}
.vertical-button__btn,
.vertical-button__btn:focus,
.vertical-button__btn:active {
background: none;
border: none;
display: inline;
font: inherit;
margin: 0;
padding: 0;
outline: none;
outline-offset: 0;
position: absolute;
top: 0px;
transform-origin: left top;
transform: rotate(90deg) translateX(-32%);
float: right;
padding: 5px;
cursor: pointer;
cursor: hand;
}
.vertical-button__stroke {
width: 1000px;
height: 1px;
background: #000;
}
<div id="app">
<div data-reactroot="">
<div class="l-container">
<div class="l-section l-section__bg">
<div class="l-wrapper">
<div class="project project--active">
<div class="project__image"></div>
<div class="project__text">
<h3 class="project__heading">Title</h3>
<div class="vertical-button">
<button class="vertical-button__btn">Description</button>
<div class="vertical-button__stroke"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Edit
I have found that if I remove this piece of HTML the button becomes clickable...
<div class="project__image"></div>
But this still doesn't help me understand why it's happening or how to fix it! I cannot actually remove that div in the real project.
I don't have IE to test, but I can tell you some ideas from my experience.
1. Check if another element is overlapping your button.
Being IE, it may handle CSS differently, hence overlapping. Since removing that image class div resolves the problem, I'd guess this would be the cause of the problem.
2. Validate the HTML.
Forgetting to close tags can create very, very bizarre bugs, also difficult to find.
3. Try turning that button into an anchor <a>
There could be browsers who won't handle the click event properly.
4. Stop using IE :)
At least use Edge.
I'm learning HTML and CSS and have some problems. Thare are 3 html elements.
First one is navigation bar.
Seconde one is button in that navigation.
Third one is dropdown menu.
Basicly, i wont on hover of 2nd element slide down 3th one.
And i get that. Problem is 3th element when sliding down it appears OVER 1st and 2nd. element. With opacity 0.99 i managed to slid it UNDER element 2. But its still OVER element 1.
How can i put it under all. Is it possible?
Here is example of my code. https://jsfiddle.net/eth66zea/
.su-drop {
position: absolute;
left: 0px;
top: -100px;
height: 100px;
min-width: 200px;
background-color: greenyellow;
transition: all 0.333s;
z-index: -1;
display: inline;
opacity: 0.99
}
.su-header {
position: relative;
height: 70px;
color: white;
background-color: black;
border-bottom: 2px #1f7caf solid;
margin-bottom: 10px;
z-index: 5;
}
.su-header .su-ul {
position: relative;
list-style-type: none;
font-size: 16px;
margin-top: 0px;
margin-bottom: 0px;
margin-left: 10%;
}
.su-header .su-ul .su-li{
position: relative;
float: left;
padding: 10px 10px;
line-height: 50px;
min-width: 100px;
text-align: center;
transition: all 0.6s;
cursor: pointer;
display: inline;
}
.su-header .su-ul .su-li:hover{
background-color: #1f7caf;
}
.su-header .su-li:last-child:hover > .su-drop{
top: 70px;
}
<div class="su-header">
<ul class="su-ul">
<li class="su-li"><i class="fa fa-heartbeat" aria-hidden="true"></i></li>
<li class="su-li">Test1</li>
<li class="su-li">Test2</li>
<li class="su-li">
Dropdown
<div class="su-drop"></div>
</li>
</ul>
</div>
Thx for your help.
Here is one way of doing it that gets around the z-index problem.
Instead of doing the transition on the top offset, you can try doing the transition on the height value.
Position the .su-drop element where you need it (bottom of .su-li) and give it an initial height of 0. On hover, you then set the height to the desired value.
If you want the sliver of color at the top, you would need to add a second element, .su-drop-up, but this may be optional.
If you don't have a height value for .su-drop, then you might need to alter your HTML, it all depends on the details of your layout and design.
.su-drop {
position: absolute;
left: 0px;
bottom: 0px;
height: 0px;
min-width: 200px;
background-color: greenyellow;
transition: all 0.333s;
z-index: -1;
display: inline;
opacity: 0.97
}
.su-drop-up {
position: absolute;
left: 0px;
top: -10px;
height: 10px;
min-width: 200px;
background-color: greenyellow;
transition: all 0.333s;
z-index: -1;
display: inline;
opacity: 0.97
}
.su-header {
position: relative;
height: 70px;
color: white;
background-color: black;
border-bottom: 2px #1f7caf solid;
margin-bottom: 10px;
z-index: 5;
opacity: 1;
}
.su-header .su-ul {
position: relative;
list-style-type: none;
font-size: 16px;
margin-top: 0px;
margin-bottom: 0px;
margin-left: 10%;
opacity: 0.98;
}
.su-header .su-ul .su-li {
position: relative;
float: left;
padding: 10px 10px;
line-height: 50px;
min-width: 100px;
text-align: center;
transition: all 0.6s;
cursor: pointer;
display: inline;
}
.su-header .su-ul .su-li:hover {
background-color: #1f7caf;
}
.su-header .su-li:last-child:hover > .su-drop {
height: 100px;
bottom: -100px;
}
.su-header .su-li:last-child:hover > .su-drop-up {
height: 0px;
}
<div class="su-header">
<ul class="su-ul">
<li class="su-li"><i class="fa fa-heartbeat" aria-hidden="true"></i>
</li>
<li class="su-li">Test1</li>
<li class="su-li">Test2</li>
<li class="su-li">
Dropdown
<div class="su-drop-up"></div>
<div class="su-drop"></div>
</li>
</ul>
</div>
Change your Height Property
.su-drop {
position: absolute;
left: 0px;
top:70px;
height: 0px;
min-width: 200px;
background-color: greenyellow;
transition: all 0.333s;
z-index: -1;
display: inline;
opacity: 0.97
}
.su-header .su-li:last-child:hover > .su-drop{
height:100px;
}
Working Demo https://jsfiddle.net/Rahul_Ravi/eth66zea/3/
I prefer CSS only solution; I can change HTML structure; Always only single line of text
TL;DR;
How to hide top part of text instead of bottom:
div {
overflow: hidden;
height: 11px;
}
<div>HOME</div>
Full example
I want to hide top of the text line so I can simulate transition effect:
div {
height: 20px;
width: 100px;
text-align: center;
}
div span {
display: block;
overflow: hidden;
transition: all 500ms ease-in-out;
height: 20px;
}
div .default {
color: black;
background-color: #f0f0f0;
}
div .hover {
height: 0;
color: white;
background-color: black;
}
div:hover .hover {
height: 25px;
}
div:hover .default {
height: 0px;
}
<div>
<span class="default">HOME</span>
<span class="hover">HOME</span>
</div>
As you can see in example .hover is currently sliding from bottom because text is hidden from bottom to top when height is reduced.
I want to hide text from top to bottom, so that it will look like same text is inverting it's color.
Are you against if I use pseudo elements to do it ? I play with bottom height to make it appears from top to bottom with the text in content property.
div .default {
display: block;
overflow: hidden;
height: 20px;
position: relative;
color: black;
background-color: #f0f0f0;
}
div .default:after { content: "Home"; position: absolute; left: 0; bottom: 100%; right: 0; background: #000; color: #fff; text-transform: uppercase; transition: all 500ms ease-in-out;}
div .default:hover:after { bottom: 0; }
HTML
<div>
<span class="default">HOME</span>
</div>
Like this
Other solution keeping the structure and avoid text in content property
<div>
<span class="default">HOME</span>
<span class="black">HOME</span>
</div>
CSS
div .black { position: absolute; left: 0; bottom: 100%; right: 0; background: #000; color: #fff; text-transform: uppercase; transition: all 500ms ease-in-out;}
div .default:hover ~ .black { bottom: 0; }
Fiddle with 2nd solution
I have solved that by using absolute positioned element over origin item:
div {
height: 20px;
width: 100px;
text-align: center;
position: relative;
}
div span {
display: block;
overflow: hidden;
transition: all 500ms ease-in-out;
height: 20px;
}
div .default {
color: black;
background-color: #f0f0f0;
/* ADDED */
position: absolute;
left: 0;
z-index: 10;
top: 0;
width: 100%;
height: 100%;
}
div .hover {
height: 20px;
color: white;
background-color: black;
}
div:hover .default {
height: 0px;
}
<div>
<span class="default">HOME</span>
<span class="hover">HOME</span>
</div>
Given your first example, this one hides top part of the text. Just play around with the line-height on your animation
Just add on your div span style:
line-height: 5px; /* play with the value till desired look is reached*/
https://jsfiddle.net/w0ydLg9h/