Text change animation CSS only (display none animation) - html

I have been trying to create animation of text appearing/disappearing.
But this is well known problem of animating display property.
I have tried to use opacity and position instead but still no luck.
I don't want to animate this in only one way, I'm just trying to hide one text and show another with arrow animation. But if it is possible to implement this transition in another way, for instance flip, fade or whatever.
Here is my code
HTML
<div class="wrapper">
<nav class="series-navigation">
<div class="series-navigation__container">
<div class="series-navigation__direction series-navigation__direction--previous">
<div class="series-navigation-item series-navigation-item--previous">
<a href="#" class="series-navigation-item__link">
<span class="sop-arrow-left series-navigation-item__icon series-navigation-item__icon--previous"></span>
<span class="series-navigation-item__title series-navigation-item__title--part">Part 1 </span>
<span class="series-navigation-item__title series-navigation-item__title--name">Article name of Part 1</span>
</a>
</div>
</div>
<div class="series-navigation__divider"></div>
<div class="series-navigation__direction series-navigation__direction--next">
<div class="series-navigation-item series-navigation-item--next">
<a href="#" class="series-navigation-item__link">
<span class="series-navigation-item__title series-navigation-item__title--part">Part 3</span>
<span class="series-navigation-item__title series-navigation-item__title--name">Article name of Part 3</span>
<span class="sop-arrow-right series-navigation-item__icon series-navigation-item__icon--next"></span>
</a>
</div>
</div>
</div>
</nav>
</div>
CSS
.sop-arrow-right:before {
content: ">";
}
.sop-arrow-left:before {
content: "<";
}
.wrapper {
margin-top: 1.25em;
overflow: hidden;
font-size: 1.25em;
padding: 1em;
background-color: #fff;
border-radius: 5px;
}
.series-navigation-item__link:hover .series-navigation-item__title--part,
.series-navigation-item__title--name {
visibility: hidden;
opacity: 0;
position: absolute;
}
.series-navigation-item__link:hover .series-navigation-item__title--name,
.series-navigation-item__title--part {
visibility: visible;
opacity: 1;
position: relative;
}
.series-navigation {
text-align: center;
display: block;
width: 100%;
}
.series-navigation__container {
position: relative;
width: 100%;
}
.series-navigation__divider {
position: absolute;
vertical-align: middle;
display: inline-block;
height: 100%;
width: 1px;
background: #52b3d9;
}
.series-navigation__direction {
position: relative;
padding-top: 1.25em;
padding-bottom: 1.25em;
vertical-align: middle;
display: inline-block;
width: 48%;
}
.series-navigation__direction--next {
padding-right: 0.25em;
}
.series-navigation__direction--previous {
padding-left: 0.25em;
}
.series-navigation-item {
display: block;
width: 100%;
}
.series-navigation-item__link {
width: 100%;
}
.series-navigation-item__link:hover .series-navigation-item__icon--next {
margin-right: -0.625em;
margin-left: 0.625em;
}
.series-navigation-item__link:hover .series-navigation-item__icon--previous {
margin-left: -0.625em;
margin-right: 0.625em;
}
.series-navigation-item__title {
font-size: 1em !important;
display: inline-block;
vertical-align: middle;
width: 90%;
}
#media only screen and (max-width: 768px) {
.series-navigation-item__title {
width: 80%;
font-size: 0.875em !important;
}
}
.series-navigation-item__title--part {
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
-o-transition: all 0.5s;
transition: all 0.5s;
}
.series-navigation-item__title--name {
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
-o-transition: all 0.5s;
transition: all 0.5s;
}
.series-navigation-item__icon {
width: 10%;
vertical-align: middle;
display: inline-block;
font-size: 1.4375em !important;
-webkit-transition: all 0.5s;
-moz-transition: all 0.5s;
-o-transition: all 0.5s;
transition: all 0.5s;
}
.series-navigation-item--previous {
padding-left: 0;
text-align: left;
}
.series-navigation-item--previous .series-navigation-item__title {
padding-right: 0.625em;
}
.series-navigation-item--next {
padding-right: 0;
text-align: right;
}
.series-navigation-item--next .series-navigation-item__title {
padding-left: 0.625em;
}
And live example as well https://jsfiddle.net/CROSP/ebztkwx1/14/
As you can see the animation looks ugly (probably because of position property), furthermore this doesn't work in Safari browser (no animation).
I would be grateful for any help or advice how to achieve desired result.
Thanks.
P.S. no JS & poorly supported browser features.

Related

How can I make a div that is set in pixels resize according to the page?

I have a progress bar that uses arrows but the only way I know how to make it is using pixels. So I am wondering if there is a way to create this progress bar using pixels, and then change its size according to the page. I have looked at similar questions, but none pertain to the type of element I am creating. Attached is what the bar currently looks like, and I want to be able to make it adaptable to the screen size.
.containerr {
font-family: 'Lato', sans-serif;
float: left;
position: relative;
width: 70%;
height: 100%;
}
.wrapperr {
float: left;
width: 70%;
height: 100%;
position: relative;
/*overflow:auto;*/
}
.pull-right {
}
a:hover {
color: #999;
}
/* Breadcrups CSS */
.arrow-steps {
zoom: 1.4;
position: relative;
display: inline-flex;
vertical-align: top;
}
.arrow-steps .step {
font-size: 100%;
text-align: center;
color: #666;
cursor: default;
margin: 0 3px;
padding: 10px 10px 10px 30px;
min-width: 180px;
float: left;
position: relative;
background-color: #d9e3f7;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
transition: background-color 0.2s ease;
}
.arrow-steps .step:after, .arrow-steps .step:before {
content: " ";
position: absolute;
top: 0;
right: -17px;
width: 0;
height: 0;
border-top: 20px solid transparent;
border-bottom: 19px solid transparent;
border-left: 17px solid #d9e3f7;
z-index: 2;
transition: border-color 0.2s ease;
}
.arrow-steps .step:before {
right: auto;
left: 0;
border-left: 17px solid #333;
z-index: 0;
}
.arrow-steps .step:first-child:before {
border: none;
}
.arrow-steps .step:first-child {
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
.arrow-steps .step span {
position: relative;
}
.arrow-steps .step span:before {
opacity: 0;
content: "✔";
position: absolute;
top: -2px;
left: -20px;
}
.arrow-steps .step.done span:before {
opacity: 1;
-webkit-transition: opacity 0.3s ease 0.5s;
-moz-transition: opacity 0.3s ease 0.5s;
-ms-transition: opacity 0.3s ease 0.5s;
transition: opacity 0.3s ease 0.5s;
}
.arrow-steps .step.current {
color: #fff;
background-color: #23468c;[![enter image description here][1]][1]
}
html
<div class="containerr">
<div class="wrapperr">
<div class="arrow-steps clearfix">
<div runat="server" id="first" class="step">
<asp:LinkButton ID="machineLink" CssClass="arrowTexts" runat="server" OnClick="machineLink_Click" OnClientClick="getCoordinates()">Safety</asp:LinkButton>
</div>
<div runat="server" id="second" class="step">
<asp:LinkButton ID="estopLink" CssClass="arrowTexts" runat="server" OnClick="estop_Click" OnClientClick="getCoordinates()">Estop Reset
</asp:LinkButton>
</div>
<div runat="server" id="third" class="step">
<asp:LinkButton ID="startLink" CssClass="arrowTexts" runat="server" OnClick="start_Click" OnClientClick="getCoordinates()">Start</asp:LinkButton>
</div>
</div>
</div>
</div>
You can utilize vh vw vmin and vmax to make your progress-bar responsive.
See this codepen

How to get a child element to change on hover over parent element

I am trying to get the width and height of the image #add-cc-img when hovering over the parent element #add-new-cc + .credit-card. How can I keep the parent's width and height to remain in its original form and only change the size of the image?
.credit-card {
border: 1px solid #CDCDCD;
width: 30%;
height: 250px;
display: inline-block;
margin: 20px 3% 20px 0;
vertical-align: top;
}
.credit-card-inner {
margin: 25px;
}
#add-new-cc {
cursor: pointer;
transition: .5s;
-webkit-transition: .5s;
}
#add-new-cc:hover,
#add-cc-img {
background: #F7F7F7;
transition: .5s;
-webkit-transition: .5s;
height: 125px;
width: 125px;
}
#add-new-cc-title {
font-size: 1.3em;
margin-bottom: 40px;
text-align: center;
}
#add-cc-img {
height: 100px;
width: 100px;
display: block;
margin: 0 auto;
}
<div class="credit-card" id="add-new-cc">
<div class="credit-card-inner">
<h3 class="blue sans-pro" id="add-new-cc-title">Add New Card</h3>
<img src="images/add-circle.png" alt="Add New Credit Card" id="add-cc-img">
</div>
</div>
Use transform: scale, it will resize the image in a much better (looking) way
(and remove the comma in #add-new-cc:hover #add-cc-img { ... })
I added transition: .5s; to the #add-cc-img { ... } rule, so it will animate on un-hover as well.
.credit-card {
border: 1px solid #CDCDCD;
width: 30%;
height: 250px;
display: inline-block;
margin: 20px 3% 20px 0;
vertical-align: top;
}
.credit-card-inner {
margin: 25px;
}
#add-new-cc {
cursor: pointer;
transition: .5s;
-webkit-transition: .5s;
}
#add-new-cc-title {
font-size: 1.3em;
margin-bottom: 40px;
text-align: center;
}
#add-cc-img {
height: 100px;
width: 100px;
display: block;
margin: 0 auto;
transition: .5s;
}
#add-new-cc:hover #add-cc-img {
background: #F7F7F7;
transition: .5s;
transform: scale(1.25);
}
<div class="credit-card" id="add-new-cc">
<div class="credit-card-inner">
<h3 class="blue sans-pro" id="add-new-cc-title">Add New Card</h3>
<img src="images/add-circle.png" alt="Add New Credit Card" id="add-cc-img">
</div>
</div>
it seems you don't need to use comma here: #add-new-cc:hover, #add-cc-img . Without comma it seems to work as it should
.credit-card {
border: 1px solid #CDCDCD;
width: 30%;
height: 250px;
display: inline-block;
margin: 20px 3% 20px 0;
vertical-align: top;
}
.credit-card-inner {
margin: 25px;
}
#add-new-cc {
cursor: pointer;
transition: .5s;
-webkit-transition: .5s;
}
#add-new-cc:hover
#add-cc-img {
background: #F7F7F7;
transition: .5s;
-webkit-transition: .5s;
height: 125px;
width: 125px;
}
#add-new-cc-title {
font-size: 1.3em;
margin-bottom: 40px;
text-align: center;
}
#add-cc-img {
height: 100px;
width: 100px;
display: block;
margin: 0 auto;
}
<div class="credit-card" id="add-new-cc">
<div class="credit-card-inner">
<h3 class="blue sans-pro" id="add-new-cc-title">Add New Card</h3>
<img src="images/add-circle.png" alt="Add New Credit Card" id="add-cc-img">
</div>
</div>
When you put a comma between selectors, you are creating a list of different selectors that will execute one rule. This is what you have:
#add-new-cc:hover, #add-cc-img {
background: #F7F7F7;
transition: .5s;
-webkit-transition: .5s;
height: 125px;
width: 125px;
}
Instead, you need a descendant selector to make this work (replace the comma with a space):
#add-new-cc:hover #add-cc-img {
background: #F7F7F7;
transition: .5s;
height: 125px;
width: 125px;
}
.credit-card {
border: 1px solid #CDCDCD;
width: 30%;
height: 250px;
display: inline-block;
margin: 20px 3% 20px 0;
vertical-align: top;
}
.credit-card-inner {
margin: 25px;
}
#add-new-cc {
cursor: pointer;
transition: .5s;
-webkit-transition: .5s;
}
#add-new-cc:hover #add-cc-img {
background: #F7F7F7;
transition: .5s;
height: 125px;
width: 125px;
}
#add-new-cc-title {
font-size: 1.3em;
margin-bottom: 40px;
text-align: center;
}
#add-cc-img {
height: 100px;
width: 100px;
display: block;
margin: 0 auto;
}
<div class="credit-card" id="add-new-cc">
<div class="credit-card-inner">
<h3 class="blue sans-pro" id="add-new-cc-title">Add New Card</h3>
<img src="http://i.imgur.com/60PVLis.png" alt="Add New Credit Card" id="add-cc-img">
</div>
</div>

Image transition on hover

I am having two different issues. The first is really irritating. I am attempting to align the text with the image inside of the first box, so that they are side-by-side an inline fashion. I am not sure what I am doing wrong and I do not want to use floats.
Secondly, I am attempting to get the image to transform: translate on the x-axis on hover. The thing is, I want the image to transform on the .extra-box:hover...not on the actual image, but I only want the image to move. I cannot figure this out.
What am I doing wrong?
#extra {
margin: 25px auto;
width: 460px;
height: auto;
}
.extra-box {
position: relative;
width: 40%;
padding: 8px;
border-radius: 3px;
/*border: 1px solid #739BAF;*/
border: 2px solid black;
display: inline-block;
background: none;
transition: 0.5s ease;
}
.extra-box:hover {
border: 2px solid red;
transition: 0.5s ease;
}
.extra-box:first-child {
margin-left: 0;
width: 40%;
margin-right: 10%;
}
.extra-box:last-child {
width: 40%;
}
.extra-box a {
text-decoration: none;
}
.extra-box-text {
color: black;
font-size: 1em;
display: inline-block;
width: auto;
}
.extra-box-icon img {
padding-left: 5px;
width: 15px;
height: auto;
display: inline-block;
-webkit-transition: all .5 ease-in-out;
transition: all .5 ease-in-out;
/*transform: translateX(30px);
-webkit-transform: translateX(30px);*/
}
<div id="extra"><div class="extra-box">
<a href="contact">
<div class="extra-box-text">Need help?<br>Contact Us Now</div><div class="extra-box-icon"><img src="icons/right-arrow.png"></div>
</a>
</div><div class="extra-box">
<a href="register">
<div class="extra-box-text">Need an account?<br>Register Now</div>
</a>
</div>
</div>
As other answers pointed out, you were missing a display: inline-block, but the problem was in .extra-box-icon
I have also added the transform for the image: (See the beginning of the CSS)
.extra-box-icon {
display: inline-block;
}
img {
transition: transform 1s;
}
.extra-box:hover img {
transform: translateX(-100px);
}
#extra {
margin: 25px auto;
width: 460px;
height: auto;
}
.extra-box {
position: relative;
width: 40%;
padding: 8px;
border-radius: 3px;
/*border: 1px solid #739BAF;*/
border: 2px solid black;
display: inline-block;
background: none;
transition: 0.5s ease;
}
.extra-box:hover {
border: 2px solid red;
transition: 0.5s ease;
}
.extra-box:first-child {
margin-left: 0;
width: 40%;
margin-right: 10%;
}
.extra-box:last-child {
width: 40%;
}
.extra-box a {
text-decoration: none;
}
.extra-box-text {
color: black;
font-size: 1em;
display: inline-block;
width: auto;
}
.extra-box-icon img {
padding-left: 5px;
width: 15px;
height: auto;
display: inline-block;
-webkit-transition: all .5 ease-in-out;
transition: all .5 ease-in-out;
/*transform: translateX(30px);
-webkit-transform: translateX(30px);*/
}
<div id="extra">
<div class="extra-box">
<a href="contact">
<div class="extra-box-text">Need help?
<br>Contact Us Now</div>
<div class="extra-box-icon">
<img src="icons/right-arrow.png">
</div>
</a>
</div>
<div class="extra-box">
<a href="register">
<div class="extra-box-text">Need an account?
<br>Register Now</div>
</a>
</div>
</div>
Add vertical-align:top; in .extra-box class to align it to same level.
to fix the alignment issue and if you don't want to use float, you can change the display property of .extra-box-text and extra-box-text img to inline-block
.extra-box-text, .extra-box-text img{
display:inline-block;
width: /*adjust as needed*/
}
to deal with the animation, i suggest you set the image itself as a background of .extra-box, you would then change the background-position on hover
Hope this helps

Centering an element between two siblings in flexbox [duplicate]

This question already has answers here:
Keep the middle item centered when side items have different widths
(12 answers)
Closed 5 years ago.
My title is being centered inside the flex box content area of my webpage. It's about 30 pixels to the right. Should I change the dimensions of the flex box? If so, how? Advice is greatly appreciated!
a {
outline: 0;
}
body {
background: linear-gradient(to bottom, #1D4350, #A43931);
background-attachment: scroll;
font-family: 'PT Mono', monospace;
}
html,
body,
.wrapper {
max-width: 100%;
min-height: 100%;
min-width: 960px;
margin: 0 auto;
}
.wrapper {
position: relative;
}
.content {
height: 1200px;
}
.header {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: space-between;
}
.Octagon {
color: #2aa186;
line-height: 30%;
margin-top: 25px;
}
.LT {
color: #3a5454;
line-height: 0;
font-style: italic;
text-align: center;
position: relative;
bottom: 33px;
}
.boi {
position: relative;
cursor: pointer;
margin-right: 30px;
padding: 8px 18px;
border: 1px solid #204156;
border-color: #52AEC9;
color: #52AEC9;
transition-duration: 0.25s;
transition-timing-function: ease-in-out;
border-top-left-radius: 15px;
border-bottom-left-radius: 15px;
}
.iob {
position: relative;
cursor: pointer;
margin-left: 30px;
padding: 8px 18px;
border: 1px solid #204156;
border-color: #52AEC9;
color: #52AEC9;
transition-duration: 0.25s;
transition-timing-function: ease-in-out;
border-top-right-radius: 15px;
border-bottom-right-radius: 15px;
}
.boi:active,
.iob:active {
top: 3px;
}
.boi:hover,
.iob:hover {
text-shadow: 0 0 10px #a193ff;
}
.manyarms,
.colorful {
position: absolute;
margin-top: 30px;
margin-left: 30px;
}
.A1 img {
-webkit-transition: all 0.75s ease-in-out;
-moz-transition: all 0.75s ease-in-out;
-ms-transition: all 0.75s ease-in-out;
-o-transition: all 0.75s ease-in-out;
transition: all 0.75s ease-in-out;
}
.manyarms,
.A1:hover .colorful {
-webkit-opacity: 1;
-moz-opacity: 1;
opacity: 1;
}
.A1:hover .manyarms,
.colorful {
-webkit-opacity: 0;
-moz-opacity: 0;
opacity: 0;
}
.A2 img {
-webkit-transition: all 0.75s ease-in-out;
-moz-transition: all 0.75s ease-in-out;
-ms-transition: all 0.75s ease-in-out;
-o-transition: all 0.75s ease-in-out;
transition: all 0.75s ease-in-out;
}
.sensible,
.A2:hover .BlueBoi {
-webkit-opacity: 1;
-moz-opacity: 1;
opacity: 1;
}
.A2:hover .sensible,
.BlueBoi {
-webkit-opacity: 0;
-moz-opacity: 0;
opacity: 0;
}
.sensible,
.BlueBoi {
margin-top: 30px;
margin-right: 20px;
right: 10px;
position: absolute;
}
.VS {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: space-between;
}
.verr {
padding-left: 31px;
padding-top: 263px;
}
.special {
padding-right: 71px;
padding-top: 263px;
}
.footer {
bottom: 0;
left: 0;
margin-right: 10px;
position: fixed;
text-align: right;
width: 100%;
}
<div class="wrapper">
<div class="header">
<a href="https://www.google.com/?gws_rd=ssl" target="_blank" style="text-decoration: none;">
<p class="iob">Information</p>
</a>
<h1 class="Octagon">The Pragmatic Octopus</h1>
<a href="https://www.google.com/?gws_rd=ssl" style="text-decoration: none;" target="_blank">
<p class="boi">Contact</p>
</a>
</div>
<p class="LT">Certes</p>
<div class="content">
<div class="A1">
<img src="https://s32.postimg.org/406x38nlh/imageedit_1_3827627792.jpg" alt="hecc" style="width:310px; height:250px;" class="manyarms">
<img src="https://s-media-cache-ak0.pinimg.com/736x/de/71/29/de71292c5df818b418fe09cbca9c49c2.jpg" alt="hecc2" style="width:310px; height:250px;" class="colorful">
</div>
<div class="A2">
<img src="http://www.wonderslist.com/wp-content/uploads/2014/07/Blue-ringed-octopus.jpg" alt="hecc3" style="width:310px; height:250px;" class="sensible">
<img src="http://img03.deviantart.net/a0a6/i/2010/007/6/4/octopus_by_mnk7.jpg" alt="hecc4" style="width:310px; height:250px;" class="BlueBoi">
</div>
<div class="VS">
<p style="color: #6458b7;" class="verr">Here comes a very special boi!</p>
<p style="color:#6458b7;" class="special">He loves to pose for photos!</p>
</div>
</div>
<div class="footer">
©Hecc™®
</div>
</div>
Here's the code you're using to align your flex items:
.header {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: space-between;
}
With space-between the "Information" and "Contact" elements will be positioned at opposite edges of the container.
Because a flex container aligns items based on the distribution of free space, your middle item will be centered between them, not necessarily centered on the page.
With "Information" having a computed width of 174px, and "Contact" having a computed width of 135px, the middle item is off-center by 39px.
In order for the middle item to be centered on the page, its siblings would need to be equal width, so there is an equal balance of space on both sides.
The following post has two methods for centering items in a flex container when siblings vary in size:
Methods for Aligning Flex Items along the Main Axis (see box #71)

Hover on div(1) to show div(2), if mouseout continue to show div(2) for x seconds

When I hover on the image, div(2) appears.
But I want div(2) to remain about x seconds even on mouse out.
I only want to use PURE CSS.
How can I do it?
jsFiddle
#basarilar {
float: right;
margin: 7px 357px;
width: 140px;
height: 24px;
position: relative;
z-index: 9999;
}
.yildiz {
height: 24px;
width: 24px;
background: url("http://www.kelimelerbenim.com/wp-content/themes/kelimelerbenim/images/yildiz.png") 0 0 no-repeat;
margin-left: 10px;
float: right;
transition: .50s all;
transition-delay: 5s;
}
.yildiz:hover {
background: url("http://www.kelimelerbenim.com/wp-content/themes/kelimelerbenim/images/yildiz-2.png") 0 0 no-repeat;
}
.aciklama {
display: none;
position: absolute;
width: 200px;
height: 70px;
z-index: 9999;
top: 48px;
right: 0px;
padding: 15px 15px;
font-weight: bold;
text-align: center;
}
#bumerang1 {
color: #ffffff;
background: #76ab01;
}
#bumerang:hover + #bumerang1 {
display: block;
}
#bumerang1:hover {
display: block;
}
<div id="basarilar">
<div id="bumerang" class="yildiz"></div>
<div id="bumerang1" class="aciklama">This is my DIV</div>
</div>
Christopher Pearson was right about using transition-delays, but you'll need to change a couple of other things as well.
#basarilar {
float:right;
margin:7px 357px;
width: 140px;
height: 24px;
position: relative;
z-index: 9999;
}
.yildiz {
height:64px;
width:64px;
background:url("http://i.stack.imgur.com/vNQ2g.png?s=64&g=1") no-repeat;
margin-left:10px;
float:right;
transition: .50s all;
transition-delay: 5s;
}
.yildiz:hover {
background:url("http://i.stack.imgur.com/vNQ2g.png?s=64&g=1") 0 0 no-repeat;
}
.aciklama {
visibility: hidden; /* use visibility rather than display */
position:absolute;
width: 200px;
height: 70px;
z-index: 9999;
top:48px;
right:0px;
padding: 15px 15px;
font-weight: bold;
text-align: center;
transition-delay: 3s; /* Set transition-delay to 3s, so the mouse out is delayed */
}
#bumerang1 {
color:#ffffff;
background: #76ab01;
}
#bumerang:hover + #bumerang1 {
visibility: visible; /* use visibility rather than display */
transition-delay: 0s; /* Set transition-delay to 0s, so the mouse over is still immediate */
}
#bumerang1:hover {
display:block;
}
<div id="basarilar">
<div id="bumerang" class="yildiz"></div>
<div id="bumerang1" class="aciklama">This is my DIV</div>
</div>
You will have to use transitions with the .transition-duration. See this thread for a similar application. You can also see the W3 schools transitions pages here.