CSS transformation on out - css

I need a help I am trying to achieve animation on hamburger menu checked and unchecked. I am able to animate menu but I can not figure out how to animate left menu animation on transform to 0
&__menu {
transform: translateX(-100%);
transition: 1s ease-in-out;
// .c-hamburger--icon ~ &{
// transition: all 300ms;
// }
.c-hamburger--icon:checked ~ &{
height: 100vh;
background: #000;
width: 270px;
transform: translateX(0);
top: 0;
opacity: .7;
position: fixed;
}
}
Here is the CodePen Demo.

Apply the height and width properties to the default state of the element instead of applying it only after the menu is checked. Default values for height and width properties is auto and we cannot transition from or to auto. Thus it was resulting in an immediate hiding of the menu instead of a slow transition.
As you are using a transform: translateX(-100%) to hide the menu initially, even setting a default height and width to the element will not affect the layout. Demo with the compiled CSS is added below.
&__menu {
position: fixed;
top: 0;
height: 100vh;
width: 270px;
transform: translateX(-100%);
transition: 1s ease-in-out;
.c-hamburger--icon:checked ~ &{
background: #000;
transform: translateX(0);
opacity: .7;
}
}
Another thing to note is that the position property should also be set on the default state itself. This is needed because the position is not a transitionable property.
#import url("https://fonts.googleapis.com/css?family=Titillium+Web");
* {
padding: 0;
margin: 0;
font-size: medium;
font-family: 'Titillium Web', sans-serif;
}
.l-app__menu {
position: fixed;
top: 0;
height: 100vh;
width: 270px;
transform: translateX(-100%);
transition: 1s ease-in-out;
}
.c-hamburger--icon:checked ~ .l-app__menu {
transform: translateX(0);
background: #000;
opacity: .7;
}
.l-app__left {
float: left;
position: fixed;
background: #185a9d;
width: 50%;
height: 100%;
overflow: hidden;
}
#media (max-width: 1200px) {
.l-app__left {
position: static;
width: 100%;
height: 100vh;
background: #fff;
}
}
.l-app__right {
float: right;
background: #fff;
width: 50%;
height: 100vh;
}
#media (max-width: 1200px) {
.l-app__right {
position: static;
width: 100%;
background: #bfbfbf;
}
}
.l-app__right--inner {
padding: 50px;
}
.l-app__hamburger {
position: fixed;
z-index: 1;
}
.c-bike__image {
background: url(http://bikeshopgirl.com/wp-content/uploads/2011/10/15038.jpg) no-repeat;
background-size: contain;
min-height: 100%;
opacity: .9;
top: 0;
position: relative;
}
#media (max-width: 1200px) {
.c-bike__image {
position: static;
width: auto;
opacity: 1;
}
}
.c-bike__header {
font-size: 150%;
padding: 15px;
}
#media (max-width: 1200px) {
.c-bike__header {
padding: 0;
}
}
.c-bike__article {
letter-spacing: .3px;
padding: 10px;
}
.c-bike__article.c-bike__header {
font-size: 120%;
padding: 0;
}
.c-hamburger {
background: transparent;
display: block;
position: relative;
overflow: hidden;
margin: 0;
padding: 0;
width: 96px;
height: 96px;
font-size: 0;
text-indent: -9999px;
appearance: none;
box-shadow: none;
border-radius: none;
border: none;
cursor: pointer;
transition: background .3s;
}
.c-hamburger:focus {
outline: none;
}
.c-hamburger--icon {
display: none;
}
.c-hamburger--icon ~ .c-hamburger--htx {
transition: transform 1s;
}
.c-hamburger--icon:checked ~ .c-hamburger--htx {
transform: translate(250px, 0) rotate(90deg);
transition: 1s ease-in-out;
}
.c-hamburger--icon:checked ~ .c-hamburger--htx .c-hamburger__span {
background: none;
}
.c-hamburger--icon:checked ~ .c-hamburger--htx .c-hamburger__span::before {
top: 0;
transform: rotate(45deg);
}
.c-hamburger--icon:checked ~ .c-hamburger--htx .c-hamburger__span::after {
bottom: 0;
transform: rotate(-45deg);
}
.c-hamburger--htx__span {
transition: transform .5s;
}
.c-hamburger--htx__span::before {
transition-property: top, transform;
}
.c-hamburger--htx__span:after {
transition-property: bottom, transform;
}
.c-hamburger__span {
display: block;
position: absolute;
top: 44px;
left: 18px;
right: 18px;
height: 8px;
background: #930202;
border-radius: 5px;
}
.c-hamburger__span::before,
.c-hamburger__span::after {
position: absolute;
display: block;
left: 0;
width: 100%;
height: 8px;
background: #930202;
border-radius: 5px;
content: "";
}
.c-hamburger__span::before {
top: -20px;
}
.c-hamburger__span::after {
bottom: -20px;
}
<div class="l-app">
<div class="l-app__hamburger">
<input id="c-hamburger--icon" type="checkbox" name="c-hamburger" class="c-hamburger--icon" />
<label for="c-hamburger--icon" class="c-hamburger c-hamburger--htx">
<span class="c-hamburger__span"></span>
</label>
<nav class="l-app__menu"></nav>
</div>
<div class="l-app__left">
<div class="l-app__left--inner c-bike__image"></div>
</div>
<div class="l-app__right">
<div class="l-app__right--inner">
<section class="c-bike">
<header>
<h3 class="c-bike__header">Bike name</h3>
</header>
<article class="c-bike__article">
<header>
<h4 class="c-bike__article c-bike__header">Secion name</h4>
</header>
<p class="c-bike__article c-bike__paragraph">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce quis diam egestas, dictum augue ut, dignissim lorem. Integer eros felis, sodales at viverra et, ultricies malesuada lacus. Nullam ex orci, vulputate vitae porta eu, gravida vel arcu. Curabitur
mattis quis dolor sit amet dapibus. Etiam mattis diam id rhoncus tempor. Phasellus tristique auctor luctus. Nulla ullamcorper tempus porttitor. Sed et tincidunt sem. Morbi dictum ut orci sit amet pretium. Integer feugiat enim vitae neque commodo,
ac malesuada lacus scelerisque. Donec quis odio in ipsum facilisis auctor. Vestibulum turpis turpis, blandit sit amet tempus sed, facilisis nec tellus. Morbi elementum vulputate sem a rhoncus. Vivamus bibendum congue velit, ac hendrerit est
suscipit ac. Nunc a molestie libero.
</p>
</article>
</section>
</div>
</div>
</div>

Related

Document flow and grid height making elements appear below grid.

Having just picked up grid I am having some issues when a site is being viewed in mobile. If I set a grid to have a height of 1200px then any elements after this should appear in normal document flow, right?
So how do we deal with this on mobile when a grid is stretched further than its original height value because from what I am experiencing the element after the grid is following the normal document flow and expecting the grid to be finished at 1200px and as a result appears behind the grid element.
Here is a gif to illustrate if anyone could shed light on this it would be super helpful all mark up below also (note on JS fiddle this "bug" does not exhibit itself)
https://gyazo.com/1f3d18693c8df5a339fb5fdc09e8d2c6
HTML
<!DOCTYPE html>
<html lang="" dir="ltr">
<head>
<meta charset="utf-8">
<title>Divine Tofu - Vegan Art and Apparel</title>
<link rel="stylesheet" href = "style/style.css" type = "text/css">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://fonts.googleapis.com/css?family=Permanent+Marker" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Work+Sans" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Shadows+Into+Light+Two" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=PT+Sans" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src = "js/menuscript.js"></script>
</head>
<body>
<nav id="wrapper">
<div class="sideSpacer">
<div id="logoCont">
<img id="logo" src="images/navicons/logo.png" alt="Devine Tofu Logo" />
<div id="logoText"><img id = "logo" class="logotext" src="images/navicons/logotext.png"></div>
</div>
<div id="navWrapper">
<ul>
<a href="#apparel">
<li>Apparel</li>
</a>
<a href="#gal">
<li>Gallery</li>
</a>
<a href="#contactmetitle">
<li>Contact</li>
</a>
<a href="https://www.etsy.com/uk/shop/DivineTofu">
<li>Etsy Store</li>
</a>
</ul>
</div>
<div id="logoCont">
<img id = "logo" class="logobot" src="images/navicons/bottomCircle.png" alt="Devine Tofu Logo" />
</div>
<div id="smWrap">
<ul id="smItems">
<li><img class="icon" src="images/navicons/fb.png" /></li>
<li><img class="icon" src="images/navicons/insta.png" /></li>
<li><img class="icon" src="images/navicons/twitter.png" /></li>
</ul>
</div>
</div>
<a href="https://www.etsy.com/uk/shop/DivineTofu">
Etsy Store
</a>
</nav>
<div id = "grid">
<div id = "grid-item1">
<h1>Commissions</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam vehicula, felis ut tempus pulvinar, lorem urna imperdiet velit, ac semper lectus dolor at odio. Proin vitae sapien ex. Sed at varius diam. Fusce sit amet nulla lacinia, sodales leo eu, porta urna. Vestibulum rhoncus facilisis nisl vel dapibus. Vestibulum mollis egestas bibendum. Curabitur fringilla felis vitae nunc efficitur viverra. Nunc eleifend faucibus sodales. Donec libero magna, efficitur vel nisi non, tempus tincidunt quam.</p>
<!-- Slider -->
<img src = "images/Gallery/gallery3.png">
</div>
<div id = "grid-item2">
<h1>Warcraft Chibis</h1>
<br>
<p>Sed commodo turpis in nulla ultricies, ac volutpat turpis tristique. Sed a turpis dictum, posuere arcu sit amet, sodales eros. Maecenas in eleifend lacus. Phasellus mattis eros et justo egestas pharetra. Etiam ac tortor ut orci dapibus laoreet.</p>
</div>
<div id = "grid-item3">
<img src = "images/chibi/tcomm5.png" id = "imgtrans">
<img src = "images/chibi/tcomm1.png" id = "imgtrans">
<img src = "images/chibi/tcomm3.png" id = "imgtrans">
<img src = "images/chibi/tcomm2.png" id = "imgtrans">
<img src = "images/chibi/tcomm7.png" id = "imgtrans">
<img src = "images/chibi/tcomm10.png" id = "imgtrans">
</div>
<div id = "grid-item4">
<br>
<h1>Original Artwork</h1>
<br>
<p>Sed commodo turpis in nulla ultricies, ac volutpat turpis tristique. Sed a turpis dictum, posuere arcu sit amet, sodales eros. Maecenas in eleifend lacus. Phasellus mattis eros et justo egestas pharetra. Etiam ac tortor ut orci dapibus laoreet.</p>
</div>
<div id = "grid-item5">
<img src = "images/Gallery/icongall1.png" id = "imgtrans">
<img src = "images/Gallery/icongall6.png" id = "imgtrans">
<img src = "images/Gallery/icongall3.png" id = "imgtrans">
<img src = "images/Gallery/icongall4.png" id = "imgtrans">
<img src = "images/Gallery/icongall5.png" id = "imgtrans">
<img src = "images/Gallery/icongall2.png" id = "imgtrans">
</div>
</div>
<!--This is the red bar -->
<div class = "aftergrid"> </div>
</body>
</html>
CSS
*{
box-sizing: border-box;
}
.aftergrid {
width: 100%;
height: 40px;
background-color: red;
}
#grid {
margin: 0 auto;
display: grid;
max-width: 100%;
height:1200px;
grid-template-columns: repeat(1, 1fr);
grid-template-rows: repeat(8,1fr);
grid-gap: 5px 5px;
}
#grid div {
background-color: hsla(126, 100%, 100%, 0.63);
box-shadow: 0px 20px 250px 10px #fffdd0 inset;
}
#grid:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
.fixed-width {
max-width: 90%;
margin:0 auto;
}
h1 {
text-align: center;
}
#grid-item1{
background-color: aliceblue;
text-align: center;
}
#grid-item1 p{
position: relative;
margin-bottom: 1em;
padding: 1em;
animation-name: fadeinleft;
animation-duration: 1s;
animation-timing-function: ease-in-out;
}
#grid-item1 h1 {
position: relative;
animation-name: fadeinright;
animation-duration: 1s;
animation-timing-function: ease-in-out;
}
#keyframes fadeinleft{
0% {left:-50px;
opacity: 0;
}
80% {left: 10px;
}
100% {left:0px;
opacity: 1;}
}
#keyframes fadeinright {
0% {left:50px;
opacity: 0;
}
80% {left: -10px;
}
100% {left:0px;
opacity: 1;}
}
#grid-item1>img{
width: 80%;
}
#grid-item2{
grid-row: 4/5;
background-color: aliceblue;
display: flex;
flex-direction: column;
align-items: center;
}
#grid-item2 p {
padding: 1em;
display: flex;
}
#grid-item3{
grid-row: 5/6;
background-color: aliceblue;
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
}
#grid-item4{
grid-row: 6/7;
background-color: aliceblue;
display: flex;
flex-direction: column;
align-items: center;
}
#grid-item4 p {
padding:1em;
}
#grid-item5{
grid-row: 7/8;
background-color: aliceblue;
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
}
.icon {
max-width: 80%;
margin: 0 auto;
}
#imgtrans{
width: 32%;
transition: all .2s ease-in-out;
padding: 5px;
overflow: auto;
position: relative;
z-index: 3;
}
#imgtrans:hover{
transform: scale(1.1);
}
#navWrapper ul li:hover {
opacity: 1;
filter: alpha(opacity=0.5);
background-color: rgba(255, 74, 1, 0.54);
}
#navWrapper ul {
margin: 0 auto;
width:96%;
}
#navWrapper ul li {
text-align: center;
margin: 10px 5px 10px 0px;
padding: 1%;
color:white;
opacity: 0.6;
transition: background-color 0.25s, opacity 0.25s ease-in;
border-radius: 10px 10px 10px 10px;
-moz-border-radius: 10px 10px 10px 10px;
-webkit-border-radius: 10px 10px 10px 10px;
width:98%;
font-size: 28px;
font-family: 'Shadows Into Light Two', cursive;
}
#navWrapper ul a {
text-decoration: none;
}
#parallax {
background-image: url(../images/parallaxbg.png);
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: fixed;
opacity: 0.1;
height: 100%;
width: 100%;
z-index: 0;
margin: 0 auto;
}
.sideSpacer {
position:fixed;
top:0;
left:0;
height:100vh;
width:220px;
background-color: hsla(36, 100%, 50%, 0.80);
z-index: 2;
transition: width .5s ease-out;
}
.sideSpacer:hover {
width:250px;
}
#flexcont{
display: block;
}
#flexlist{
height: 100%;
transition: all 1s;
}
#navIcons {
display: flex;
flex-direction: row;
justify-content: space-between;
}
.mobileLogo {
width:100px;
height: 100px;
}
.mobileNavButton {
width: 50px;
height: 50px;
align-self: center;
margin-right: 15px;
}
.mobileNavButton:hover {
cursor: pointer;
}
#smWrap {
width:100%;
}
#smItems{
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-around;
}
#smItems li{
text-align: center;
opacity: 0.6;
width:66px;
margin-bottom: 10px;
transition: width 2s, opacity 0.25s ease-in;
}
#smItems li:hover {
opacity: 0.9;
}
#logoCont{
margin:0 auto;
width:100%;
}
#logoCont{
font-weight: bold;
width: 100%;
opacity: 0.8;
color:white;
transition: width 2s, opacity 0.5s ease-in;
}
#logoCont:hover {
opacity: 1;
filter: alpha(opacity=0.5);
}
#logo{
max-width: 94%;
margin-left:3%;
margin-right:3%;
margin-top: 5%;
}
#logoText {
text-align: center;
}
.logobot{
max-width: 80%;
margin:10%;
padding-top: 1em;
}
#topNav {
width: 100%;
background-color: hsla(36, 100%, 50%, 0.80);
}
/* Tablet */
#media only screen and (min-width: 500px) {
#grid {
max-width: 90%;
margin: 0 auto;
}
.fixed-width {
width: 80%;
margin: 0 auto;
}
}
#media only screen and (max-width: 900px){
.sideSpacer {
display:none;
}
}
/* Desktop */
#media only screen and (min-width: 900px) {
#grid {
width: 70%;
grid-template-columns: repeat(8, 1fr);
grid-template-rows: repeat(12,1fr);
grid-gap: 5px 5px;
margin-left: 25%;
}
#grid-item1{
grid-row: 2/12;
grid-column: 5/9;
background-color: aliceblue;
}
#grid-item2{
grid-row: 1/4;
grid-column: 1/4;
background-color: aliceblue;
}
#grid-item3{
grid-row: 4/7;
grid-column: 1/4;
background-color: aliceblue;
}
#grid-item4{
grid-row: 7/10;
grid-column: 1/4;
background-color: aliceblue;
}
#grid-item5{
grid-row: 10/13;
grid-column: 1/4;
background-color: aliceblue;
}
#topNav {
display: none;
}
.aftergrid {
margin-top: 25px;
}
}
I have solved it I should have been using height auto all along.

Half transparent circle in another half circle

I have to make such contruction like this one on the picture. There is a bubble with some fancy ending and I don't know, how to make this half transparent circle inside it.
How can I do that?
I have some image as a background.
.bubble {
background-color: #34bc74;
border-top-right-radius: 0;
border-radius: 10px;
line-height: 18px;
margin: 100px 0 0 0;
padding: 15px 65px 25px 15px;
position: relative;
width: 200px;
}
.circle {
background-color: #34bc74;
border-bottom-right-radius: 140px;
border-top-right-radius: 140px;
border-left-color: transparent;
width: 70px;
height: 140px;
position: absolute;
z-index: 1;
top: -70px;
right: -70px;
overflow: hidden;
}
.circle:after {
height: 70px;
width: 35px;
left: -35px;
z-index: 2;
content: '';
border-radius: 70px;
position: absolute;
// border: 35px solid $green;
// box-shadow: 0px 300px 0px 300px #448CCB;
}
<div class="bubble">
Donec viverra sodales imperdiet. Aliquam eget ante nec nulla hendrerit dignissim sit amet id Donec viverra sodales imperdiet. Aliquam eget ante nec nulla hendrerit dignissim sit amet id
<div class="circle"></div>
</div>
You could try create the shape using svg masking.
Here's some more info from MDN
(poor) example...
body {
background: url(https://unsplash.it/1000x1000);
}
.bubble {
background-color: #34bc74;
border-top-right-radius: 0;
border-radius: 10px;
line-height: 18px;
margin: 100px 0 0 0;
padding: 15px 65px 25px 15px;
position: relative;
width: 200px;
}
.bubble svg {
position: absolute;
right: -4em;
top: -1em;
}
<div class="bubble">
Donec viverra sodales imperdiet. Aliquam eget ante nec nulla hendrerit dignissim sit amet id Donec viverra sodales imperdiet. Aliquam eget ante nec nulla hendrerit dignissim sit amet id
<svg width="100" height="100">
<defs>
<mask id="inner-circle">
<rect width="100%" height="100%" fill="white"/>
<circle r="28" cx="40" cy="20" fill="black"/>
</mask>
</defs>
<circle id="curve" r="50" cx="50" cy="50" fill="#34bc74" mask="url(#inner-circle)" />
</svg>
</div>
Using a combination of pseudo-elements and box-shadow properties you can get close to the intended result.
Experiment and adjust height, width, and box-shadow values as required.
.bubble {
background-color: #34bc74;
border-top-right-radius: 0;
border-radius: 10px;
line-height: 18px;
margin: 100px 0 0 0;
padding: 15px 65px 25px 15px;
position: relative;
width: 200px;
}
.circle {
width: 155px;
height: 140px;
border-radius: 100%;
position: absolute;
top: -70px;
right: -45px;
overflow: hidden;
z-index: -1;
}
.circle:after {
content: "";
width: 112px;
height: 87px;
border-radius: 100%;
box-shadow: 55px -15px 0 0 #34bc74;
position: absolute;
z-index: 9;
overflow: hidden;
}
.circle:before {
content: "";
width: 112px;
height: 88px;
border-radius: 100%;
box-shadow: 72px 52px 0 0 #34bc74;
position: absolute;
z-index: 9;
overflow: hidden;
}
<div class="bubble">
Donec viverra sodales imperdiet. Aliquam eget ante nec nulla hendrerit dignissim sit amet id Donec viverra sodales imperdiet. Aliquam eget ante nec nulla hendrerit dignissim sit amet id
<div class="circle"></div>
</div>

Wordpress popup without any plugin

How can I make an easy popup on Wordpress without any plugins? This popup should be shown only for the first site visit. Any ideas, mates?
Maybe this:
codepen example
Html part in footer.php, css part in style.css and js part in main.js and that's it.
First download popup from here http://www.jqueryscript.net/lightbox/Super-Simple-Modal-Popups-with-jQuery-CSS3-Transitions.html
Now paste this code where you want to show popup into your template
<style>
html {
font-family: "roboto", helvetica;
position: relative;
height: 100%;
font-size: 100%;
line-height: 1.5;
color: #444;
}
h2 {
margin: 1.75em 0 0;
font-size: 5vw;
}
h3 { font-size: 1.3em; }
.v-center {
height: 100vh;
width: 100%;
display: table;
position: relative;
text-align: center;
}
.v-center > div {
display: table-cell;
vertical-align: middle;
position: relative;
top: -10%;
}
.btn {
font-size: 3vmin;
padding: 0.75em 1.5em;
background-color: #fff;
border: 1px solid #bbb;
color: #333;
text-decoration: none;
display: inline;
border-radius: 4px;
-webkit-transition: background-color 1s ease;
-moz-transition: background-color 1s ease;
transition: background-color 1s ease;
}
.btn:hover {
background-color: #ddd;
-webkit-transition: background-color 1s ease;
-moz-transition: background-color 1s ease;
transition: background-color 1s ease;
}
.btn-small {
padding: .75em 1em;
font-size: 0.8em;
}
.modal-box {
display: none;
position: absolute;
z-index: 1000;
width: 98%;
background: white;
border-bottom: 1px solid #aaa;
border-radius: 4px;
box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
border: 1px solid rgba(0, 0, 0, 0.1);
background-clip: padding-box;
}
#media (min-width: 32em) {
.modal-box { width: 70%; }
}
.modal-box header,
.modal-box .modal-header {
padding: 1.25em 1.5em;
border-bottom: 1px solid #ddd;
}
.modal-box header h3,
.modal-box header h4,
.modal-box .modal-header h3,
.modal-box .modal-header h4 { margin: 0; }
.modal-box .modal-body { padding: 2em 1.5em; }
.modal-box footer,
.modal-box .modal-footer {
padding: 1em;
border-top: 1px solid #ddd;
background: rgba(0, 0, 0, 0.02);
text-align: right;
}
.modal-overlay {
opacity: 0;
filter: alpha(opacity=0);
position: absolute;
top: 0;
left: 0;
z-index: 900;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.3) !important;
}
a.close {
line-height: 1;
font-size: 1.5em;
position: absolute;
top: 5%;
right: 2%;
text-decoration: none;
color: #bbb;
}
a.close:hover {
color: #222;
-webkit-transition: color 1s ease;
-moz-transition: color 1s ease;
transition: color 1s ease;
}
</style>
<section class="v-center">
<div>
<a class="js-open-modal btn" href="#" data-modal-id="popup1"> Pop Up One</a> </div>
</section>
<div id="popup1" class="modal-box">
<header>
<h3>Pop Up One</h3>
</header>
<div class="modal-body">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut commodo at felis vitae facilisis. Cras volutpat fringilla nunc vitae hendrerit. Donec porta id augue quis sodales. Sed sit amet metus ornare, mattis sem at, dignissim arcu. Cras rhoncus ornare mollis. Ut tempor augue mi, sed luctus neque luctus non. Vestibulum mollis tristique blandit. Aenean condimentum in leo ac feugiat. Sed posuere, est at eleifend suscipit, erat ante pretium turpis, eget semper ex risus nec dolor. Etiam pellentesque nulla neque, ut ullamcorper purus facilisis at. Nam imperdiet arcu felis, eu placerat risus dapibus sit amet. Praesent at justo at lectus scelerisque mollis. Mauris molestie mattis tellus ut facilisis. Sed vel ligula ornare, posuere velit ornare, consectetur erat.</p>
</div>
<footer> Close </footer>
</div>
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script>
$(function(){
var appendthis = ("<div class='modal-overlay js-modal-close'></div>");
$('a[data-modal-id]').click(function(e) {
e.preventDefault();
$("body").append(appendthis);
$(".modal-overlay").fadeTo(500, 0.7);
//$(".js-modalbox").fadeIn(500);
var modalBox = $(this).attr('data-modal-id');
$('#'+modalBox).fadeIn($(this).data());
});
$(".js-modal-close, .modal-overlay").click(function() {
$(".modal-box, .modal-overlay").fadeOut(500, function() {
$(".modal-overlay").remove();
});
});
$(window).resize(function() {
$(".modal-box").css({
top: ($(window).height() - $(".modal-box").outerHeight()) / 2,
left: ($(window).width() - $(".modal-box").outerWidth()) / 2
});
});
$(window).resize();
});
</script>

Vertical align middle text without lineheight and table-cell

I have a Teaser with a "toggle"-Animation, as can be seen on JSFiddle or below:
.ax {
height:60px;
width:150px;
background:gold;
}
.caption {
position: absolute;
left:0;
top: 35%;
overflow: hidden;
right: 0;
background-color: rgba(24,88,140,0.7);
width: 100%;
height: 52px;
z-index: 2;
-o-transition: 500ms;
-webkit-transition: 500ms;
-moz-transition: 500ms;
-ms-transition: 500ms;
transition: 500ms;
font-weight: lighter;
padding: 10px;
color: #fff;
}
a.link{
color: #fff;
overflow: hidden;
width: 80%;
margin-bottom: 30px;
font-weight: lighter;
font-size: 16px;
line-height: 22px;
}
.caption:hover {
height: 100%;
top: 0;
}
.box {
position:relative;
width:250px;
height:200px;
}
/*TABLE CELL METHOD*/
.caption2 {
position: absolute;
left:0;
top: 35%;
overflow: hidden;
right: 0;
background-color: rgba(24,88,140,0.7);
width: 100%;
height: 52px;
z-index: 2;
-o-transition: 500ms;
-webkit-transition: 500ms;
-moz-transition: 500ms;
-ms-transition: 500ms;
transition: 500ms;
font-weight: lighter;
padding: 10px;
color: #fff;
display:table;
}
.caption2:hover {
height: 100%;
top: 0;
}
a.link2{
display:table-cell;
vertical-align: middle;
overflow: hidden;
width: 80%;
margin-bottom: 30px;
font-weight: lighter;
font-size: 16px;
line-height: 22px;
}
<div class="box">
<div class="caption">
Lorem Ipsum blabla bla blahah ipsum lorem blablablahh
<p class="captiontext">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>
</div>
</div><br><br
<br><br>
table cell method (div.caption2 display:table and a.link display:table-cell + vertical-algin:middle)
<br><br>
<div class="box">
<div class="caption2">
<a class="link2" href="#">Lorem Ipsum blabla bla blahah ipsum lorem blablablahh</a>
<p class="captiontext">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>
</div>
</div>
I want to align the link in the vertical center of the blue box. The link can be a single line or two lines (at most), but it should always be centered vertically.
The CSS property lineheight doesn't work with two line links, whereas the table(-cell)-method also doesn't work (see above).
Is there any way to center both one and two line links in my box?
The display type "Flexbox" may be useful for this. Apply this CSS to the parent of the child you want centered:
display: flex;
flex-direction: column;
justify-content: center;
To verticly center any element, you can apply this style:
.element
{
position: relative;
top: 50%;
transform: translateY(-50%);
}
You will have to replace your table cells with columns in order to replicate your current styles. Credit to Sebastian Ekstrom for the solution.
Another way is vertical-align on pseudoelement:
https://codepen.io/darxide/pen/xRmYdQ
<div class="block" style="height: 300px;">
<div class="centered">
vertical center
</div>
</div>
.block:before {
content: ' ';
display: inline-block;
height: 100%;
vertical-align: middle;
}
.centered {
display: inline-block;
vertical-align: middle;
}

timing the animation in css3

I have the following code:
html:
<html>
<head>
<link rel="stylesheet" type="text/css" href="StyleSheet.css">
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>What</title>
<style type="text/css">
</style>
</head>
<body dir="rtl">
<div id="page">
<div id="bothcontainer">
<div id="littlebox1" class="littlebox1sentence">put your mouse here</div>
<div id="littlebox1" class="triangle">
<div class="triangleborder"></div>
</div>
</div>
<div id="box1">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
</div>
</div>
</body>
</html>
and the CSS3:
#page {
width: 900px;
padding: 0px;
margin: 0 auto;
direction: rtl;
position: relative;
}
#box1 {
position: relative;
width: 500px;
border: 1px solid black;
box-shadow: -3px 8px 34px #808080;
border-radius: 20px;
box-shadow: -8px 5px 5px #888888;
right: 300px;
top: 250px;
text-align: justify;
-webkit-transition: all 1s;
font-size: large;
color: Black;
padding: 10px;
background: #D0D0D0;
opacity: 0;
}
#-webkit-keyframes myFirst {
0% {
right: 300px;
top: 160px;
background: #D0D0D0;
opacity: 0;
}
100% {
background: #909090;
right: 300px;
top: 200px;
opacity: 1;
}
}
#littlebox1 {
top: 200px;
position: absolute;
display: inline-block;
}
.littlebox1sentence {
font-size: large;
padding-bottom: 15px;
padding-top: 15px;
padding-left: 25px;
padding-right: 10px;
background: #D0D0D0;
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
-webkit-transition: background .25s ease-in-out;
border-bottom: 2px solid red;
border-right: 2px solid red;
border-top: 2px solid red;
-webkit-transition-property:color, background;
-webkit-transition-duration: .25s, .25s;
-webkit-transition-timing-function: linear, ease-in;
}
#bothcontainer:hover ~ #box1 {
-webkit-transition: all 0s;
background: #909090;
right: 300px;
top: 200px;
-webkit-animation: myFirst .75s;
-webkit-animation-fill-mode: initial;
opacity: 1;
}
#bothcontainer:hover .littlebox1sentence {
background: #909090;
color:#D0D0D0
}
#bothcontainer:hover .triangle {
border-right: 20px solid #909090;
}
.triangle {
position: relative;
width: 0;
height: 0;
border-right: 20px solid #D0D0D0;
border-top: 26px solid transparent;
border-bottom: 25px solid transparent;
right: 186px;
-webkit-transition: border-right .25s ease-in-out;
margin-top: 2px;
}
.triangleborder {
position: absolute;
width: 0;
height: 0;
border-right: 22px solid red;
border-top: 28.5px solid transparent;
border-bottom: 27.5px solid transparent;
right: -20px;
-webkit-transition: border-right .25s ease-in-out;
top: -28px;
z-index: -15656567650;
}
Live example here:http://jsfiddle.net/VhGBv/
As you can see, when I put the mouse on the gray box, the backgound and the font color changing not at the same time.
My qusation is: How can I timing the animation so when I put the mouse on the gray sentense the arrow and the gray box will change their color at the same time (together)?
Fixed here: http://jsfiddle.net/VhGBv/1/
I changed this line:
.littlebox1sentence {
...
-webkit-transition-timing-function: linear, ease-in-out;
}

Resources