I am trying to realize a flipping card menu using only HTML & CSS. It is almost done except that the back side of the card takes time to display when receiving the first hover state. It's kind of doing the smooth transition move just for 90deg, then it goes instantly to display the final outcome (No more smooth transition done for the last 90deg).
After the first hover, everything goes fine.
Any suggestions?
EDIT: the snippet below has been edited to fit the correct answer.
#import url('https://fonts.googleapis.com/css?family=Open+Sans:400,700&display=swap');
.main{
height: 100vh;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
font-family: 'Open Sans', sans-serif;
background-color: #000;
}
.header{
color:white;
font-size: 2vh;
margin-bottom: 2vh;
}
.header a{
text-decoration: none;
color: white;
font-weight: bold;
}
.card{
background-color: transparent;
width: 30vh;
height: 50vh;
perspective: 1000px;
perspective-origin: center;
margin-right: 0.5vh;
}
.card > .card-container{
position: relative;
width: 100%;
height: 100%;
transition: 1s transform ease;
transform-style: preserve-3d;
background-color: transparent;
}
.card:hover > .card-container{
transform: rotateY(180deg);
}
.card-container > .front,.card-container > .back {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
.card-container > .front{
background-image: linear-gradient(to bottom right,red, yellow);
display: flex;
justify-content: center;
align-items: center;
border-radius: 0.5vh;
color: white;
font-size: 3vh;
cursor: pointer;
backface-visibility: hidden;
}
.card-container > .back{
background-color: transparent;
color: white;
font-size: 3vh;
transform: rotateY(180deg);
cursor: pointer;
}
.back > ul{
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
list-style: none;
padding: 0;
margin: 0;
width: 100%;
height: 100%;
perspective: 1000px;
perspective-origin: center ;
}
.back > ul > li{
text-align: center;
height: calc(100% - (0.2vh * 4) /5);
width: 100%;
transition: 1s transform ease;
transform-style: preserve-3d;
}
.back > ul > li:not(:last-child){
margin-bottom: 0.2vh;
}
.back > ul > li > .child-front, .back > ul > li > .child-back {
backface-visibility: hidden;
width: 100%;
height: 100%;
position: absolute;
top:0;
left: 0;
border-radius: 0.5vh;
}
.back > ul > li > .child-front{
background-image: linear-gradient(to bottom left,red, orange);
display: flex;
justify-content: center;
align-items: center;
}
.back > ul > li > .child-back{
background-color: orange;
transform: rotateX(180deg);
display: flex;
justify-content: center;
align-items: center;
}
.back > ul > li:hover{
transform: rotateX(180deg);
}
.child-back span, .child-front span{
color: white;
display: block;
}
.child-back span{
font-weight: bold;
}
<div class="main">
<div class="header">
Find me on Github
</div>
<div class="card">
<div class="card-container">
<div class="front">
<span>Hover here</span>
</div>
<div class="back">
<ul class="menu">
<li class="child">
<div class="child-front"><span>Hover here</span></div>
<div class="child-back"><span>ITEM1</span></div>
</li>
<li class="child">
<div class="child-front"><span>Hover here</span></div>
<div class="child-back"><span>ITEM2</span></div>
</li>
<li class="child">
<div class="child-front"><span>Hover here</span></div>
<div class="child-back"><span>ITEM3</span></div>
</li>
<li class="child">
<div class="child-front"><span>Hover here</span></div>
<div class="child-back"><span>ITEM4</span></div>
</li>
<li class="child">
<div class="child-front"><span>Hover here</span></div>
<div class="child-back"><span>ITEM5</span></div>
</li>
</ul>
</div>
</div>
</div>
</div>
Delete backface-visibility: hidden;:
.card-container > .front,.card-container > .back {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
It actually rotates 180deg but because of backface-visibility you don't see the whole transform. It shows you after the rotate finishes.
Related
Something on my website is bothering me.
The last menu item of my Navbar is outside it's container's background:
Here is how my CSS looks like:
.nav-menu {
display: flex;
flex-direction: column;
width: 100%;
height: 280px;
position: absolute;
top: 80px;
left: -100%;
opacity: 1;
transition: all 0.5s ease;
align-items: space-evenly;
}
.nav-menu.active {
display: flex;
flex-direction: column;
align-content: flex-start;
background: #242222;
left: 0;
opacity: 1;
transition: all 0.5s ease;
z-index: 1;
}
.nav-links {
text-align: center;
padding: 2rem;
width: 100%;
display: table;
}
.nav-links:hover {
background-color: #fff;
color: #242424;
border-radius: 0;
}
.navbar-logo {
position: absolute;
top: 0;
left: 0;
transform: translate(25%, 50%);
}
.menu-icon {
display: block;
position: absolute;
top: 0;
right: 0;
transform: translate(-100%, 60%);
font-size: 1.8rem;
cursor: pointer;
}
.fa-times {
color: #fff;
font-size: 2rem;
}
.nav-links-mobile {
display: block;
text-align: center;
margin: 2rem auto;
border-radius: 4px;
width: 80%;
text-decoration: none;
font-size: 1.5rem;
background-color: transparent;
color: #fff;
padding: 14px 20px;
border: 1px solid #fff;
transition: all 0.3s ease-out;
}
.nav-links-mobile:hover {
background: #fff;
color: #242424;
transition: 250ms;
}
}
and HTML generated by a React component looks like this:
<>
<nav className='navbar'>
<div className='navbar-container'>
<Link to='/' className='navbar-logo' onClick={closeMobileMenu}>
LOGO
</Link>
<div className='menu-icon' onClick={handleClick}>
<i className={click ? 'fas fa-times' : 'fas fa-bars'} />
</div>
<ul className={click ? 'nav-menu active' : 'nav-menu'}>
<li className='nav-item'>
<Link to='/' className='nav-links' onClick={closeMobileMenu}>
Home
</Link>
</li>
<li className='nav-item'>
<HashLink to='/#wherewefly' onClick={closeMobileMenu} className='nav-links'>
Where we fly
</HashLink>
</li>
<li className='nav-item'>
<Link
to='/services'
className='nav-links'
onClick={closeMobileMenu}
>
Promotions
</Link>
</li>
<li className='nav-item'>
<Link
to='/products'
className='nav-links'
onClick={closeMobileMenu}
>
Contact
</Link>
</li>
</ul>
{button && <Button buttonStyle='btn--outline'>LOGIN</Button>}
</div>
</nav>
</>
How can I make the last menu item (Contact) be covered by the black background too?
I have tried changing the height but the menu items "follow" and are aligned to the bottom. I can't find out how to change it though.
Edited: Picture has been updated
Remove height: 280px;.
You are using flex-box so you shouldn't be setting the height or width attributes. The idea is to allow the box to be flexible to it's contents.
If you want a fixed height you should be using flex-basis attribute.
EXAMPLE
I have had to convert your react to html to demonstrate but as you can see the code you provided works as expected. This would indicate the issue lies elsewhere in code you have not provided.
.nav-menu {
display: flex;
flex-direction: column;
width: 100%;
position: absolute;
top: 80px;
left: -100%;
opacity: 1;
transition: all 0.5s ease;
align-items: space-evenly;
}
.nav-menu.active {
display: flex;
flex-direction: column;
align-content: flex-start;
background: #242222;
left: 0;
opacity: 1;
transition: all 0.5s ease;
z-index: 1;
}
.nav-links {
text-align: center;
padding: 2rem;
width: 100%;
display: table;
}
.nav-links:hover {
background-color: #fff;
color: #242424;
border-radius: 0;
}
.navbar-logo {
position: absolute;
top: 0;
left: 0;
transform: translate(25%, 50%);
}
.menu-icon {
display: block;
position: absolute;
top: 0;
right: 0;
transform: translate(-100%, 60%);
font-size: 1.8rem;
cursor: pointer;
}
.fa-times {
color: #fff;
font-size: 2rem;
}
.nav-links-mobile {
display: block;
text-align: center;
margin: 2rem auto;
border-radius: 4px;
width: 80%;
text-decoration: none;
font-size: 1.5rem;
background-color: transparent;
color: #fff;
padding: 14px 20px;
border: 1px solid #fff;
transition: all 0.3s ease-out;
}
.nav-links-mobile:hover {
background: #fff;
color: #242424;
transition: 250ms;
}
<nav class='navbar'>
<div clas='navbar-container'>
<a class='navbar-logo'> LOGO
</a>
<div class='menu-icon'>
<i class='fas fa-times' />
</div>
<ul class='nav-menu active'>
<li class='nav-item'>
<a class='nav-links'> Home
</a>
</li>
<li class='nav-item'>
<a class='nav-links'>
Where we fly
</a>
</li>
<li class='nav-item'>
<a class='nav-links'> Promotions
</a>
</li>
<li class='nav-item'>
<a class='nav-links'> Contact
</a>
</li>
</ul>
<Button class='btn--outline'>LOGIN</Button>
</div>
</nav>
Well, the height is fixed in the CSS, if you want it to take the height the content has you need to use "fit-content".
Blockquote
The issue could be the height of the nav-menu. please use min-hight instead. This may fix your issue
.nav-menu {
display: flex;
flex-direction: column;
width: 100%;
min-height: 280px;
position: absolute;
top: 80px;
left: -100%;
opacity: 1;
transition: all 0.5s ease;
align-items: space-evenly;
}
I am trying to add an efficient box-shadow to my flex elements by following this article.
Problem is it doesn't work, this is the minified example.
I've tried setting the position: relative on nav, but it just made the ::after element the size of the whole navbar.
<nav>
<div class="nav-left">
<a href="#">
hello
</a>
</div>
<div class="nav-center"></div>
<div class="nav-right"></div>
</nav>
nav {
display: flex;
min-height: 5rem;
background-color: #402424;
align-items: stretch;
}
nav a,
nav .brand {
text-decoration: none;
align-items: center;
display: flex;
color: #AFAFAF;
}
nav a::after {
content: '';
position: absolute;
z-index: -1;
width: 100%;
height: 100%;
opacity: 0;
border-radius: 5px;
box-shadow: 0 5px 15px rgba(0,0,0,0.3);
transition: opacity 0.3s ease-in-out;
}
nav a:hover::after {
opacity: 1;
}
Try this instead,
Add to nav a
nav a{position:relative;}
also add to nav a::after
nav a::after{
top:0;
right:0;
left:0;
bottom:0;
}
body {
background: #20262E;
padding: 0;
margin: 0;
font-family: Helvetica;
}
nav {
display: flex;
min-height: 5rem;
background-color: #402424;
align-items: stretch;
}
nav a,
nav .brand {
text-decoration: none;
align-items: center;
display: flex;
color: #AFAFAF;
position:relative;
}
nav a::after {
content: '';
position: absolute;
z-index: 1;
opacity: 0;
top:0;
right:0;
left:0;
bottom:0;
border-radius: 5px;
box-shadow: 0 5px 15px rgba(0,0,0,0.3);
transition: opacity 0.3s ease-in-out;
}
nav a:hover::after {
opacity: 1;
}
.nav-left,
.nav-center,
.nav-right {
display: flex;
flex: 1;
}
.nav-left {
justify-content: flex-start;
}
.nav-center {
justify-content: center;
}
.nav-right {
justify-content: flex-end;
}
<nav>
<div class="nav-left">
<a href="#">
hello
</a>
</div>
<div class="nav-center">
</div>
<div class="nav-right">
World
</div>
</nav>
So i am currently working on a website and i have a problem aligning the flexbox items(logo and title) in the header. They always align underneath each other and i need them side by side.
I read through the similar problems of others in stackoverflow and i also have googled for min. 2 hours.
I have to say learned many things about positioning and flexbox but i can't solve it.
There are many more things that i havent really cared about yet on the website but they don't matter for now, just overlook them :'D
But if you have some Tip's i still would be very thankful cause im new into creating websites :)
#import url('https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css');
#import url('https://fonts.googleapis.com/css?family=Sniglet');
#import url('https://fonts.googleapis.com/css?family=Dosis&display=swap');
#import url('https://fonts.googleapis.com/css?family=Dancing+Script');
/*all*/
html,
body {
margin: 0;
padding: 0;
width: 100vw;
height: 100vh;
max-width: 100%;
box-sizing: border-box;
}
* {
box-sizing: inherit;
font-family: 'Dosis', sans-serif;
/*, cursive |zum kursiv*/
}
/*For PC's*/
#media screen and (min-width: 950px) {
.wrapper {
display: grid;
grid-template-columns: 100%;
grid-template-rows: auto auto auto;
/*NOT sur about the auto*/
grid-template-areas: "header" "main" "footer";
background-color: #ffc5c9;
}
/*Nav Menu*/
.navigation_wrapper {
position: relative;
}
.navigation_button {
will-change: transform;
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
position: fixed;
z-index: 1;
top: 40px;
left: 100px;
background: transparent;
cursor: pointer;
}
.navigation_button .fa {
border: 2px solid white;
border-radius: 3px;
padding: 10px;
color: white;
}
.navigation_menu ul li {
list-style: none;
font-weight: 250;
color: #79E2DD;
/*font-family: impact; könnte hier noch geändert werden*/
}
.navigation_menu {
content: '';
position: fixed;
top: 0;
right: 0;
width: 50%;
background: white;
height: 100%;
transform: skewX(0deg) translate(100%, 0);
transform-origin: top right;
transition: all .2s ease-in;
z-index: -1;
}
.navigation_menu ul {
transform: skewX(-8deg);
transform-origin: top left;
position: fixed;
left: 100px;
top: 100px;
width: 400px;
text-align: left;
}
.navigation_menu ul li {
position: relative;
z-index: 999;
font-size: 32px;
color: #F4E1A6;
line-height: 64px;
}
.navigation_menu ul li a {
border: none;
color: #FFC59;
text-decoration: none;
}
.navigation_menu.active {
transform: skewX(8deg) translate(0, 0);
}
.navigation_menu li {
opacity: 0;
transform: translate(0, 10px);
transition: all .0s ease-in .3s;
}
.navigation_menu.active li {
opacity: 1;
transform: translate(0, 0);
transition: all 0.2s ease-in 0s;
}
.navigation_menu.active li:nth-child(1) {
transition-delay: .3s;
}
.navigation_menu.active li:nth-child(2) {
transition-delay: .4s;
}
.navigation_menu.active li:nth-child(3) {
transition-delay: .5s;
}
.navigation_menu.active li:nth-child(4) {
transition-delay: .6s;
}
.navigation_menu.active li:nth-child(5) {
transition-delay: .7s;
}
.navigation_menu.active li:nth-child(6) {
transition-delay: .8s;
}
/*Scrollbar*/
/*Skeleton*/
.head_wrapper {
grid-area: header;
height: auto;
padding: 3rem 5rem 3rem;
background-image: url("../pictures/TP4.jpeg");
background-size: cover;
background-repeat: no-repeat;
border-radius: 0 0 50px 50px;
}
.main_wrapper {
grid-area: main;
margin: 2rem;
padding: 20px;
min-height: 100%;
background-color: #feeee6;
border-radius: 50px;
}
.foot_wrapper {
background-color: #f4e1a6;
grid-area: footer;
border-radius: 50px 50px 0 0;
}
/*for Sticky Footer*/
.foot_wrapper,
.push {
height: 15rem;
}
/*flex containers*/
.head_flex_container {
display: flex;
justify-content: space-between;
flex-direction: column;
flex-wrap: wrap;
}
/*flex items*/
.head_titel_container {
border: 5px solid blue;
max-height: 22rem;
min-width: 100%;
position: relative;
}
.flex_titel {
position: absolute;
right: 0;
width: 78%;
box-sizing: content-box;
border: 5px solid black;
}
.flex_logo {
width: 22%;
box-sizing: border-box;
border: 5px solid pink;
}
/*Titles*/
h1 {}
h2 {}
/*Texts*/
.index {}
/*classes*/
/*ID's*/
#logo {
height: auto;
min-width: 5rem;
max-width: 20rem;
border-radius: 100%;
box-sizing: border-box;
}
#pb1 {}
/*Decoration*/
hr {}
}
<div class="wrapper">
<div class="scroll_wrapper">
<div class="scrollbar" id="style-default">
<div class="force-overflow"></div>
</div>
<div class="navigation_wrapper">
<div class="navigation_button">
<i class="fa fa-bars"></i>
</div>
<div class="navigation_menu">
<ul>
<li>Home</li>
<li>Gallerie</li>
<li>
Kontakt</li>
<li>
<a class="active" href="hier link rein"></a>
</li>
<li>
<a class="active" href="hier link rein"></a>
</li>
</ul>
</div>
</div>
<header>
<div class="head_wrapper">
<div class="head_flex_container">
<div class="head_titel_container">
<div class="flex_logo"><img src="pictures/Logo.jpeg" alt="Logo" title="El Pastelazo" id="logo"></div>
<div class="flex_titel">
<h1>El Pastelazo</h1>
</div>
</div>
</div>
</div>
</header>
<main class="main">
<div class="main_wrapper">
<div class="home_picture"><img src="pictures/PI.jpg" alt="Picture" title="Loah" id="pb1"></div>
<div class="pagetitle">
<h2>Home</h2>
</div>
<p class="index">
<h3>Wilkommen!</h2>
<hr class="hr_01"> hier kann loah sich und ihre arbeit bzw was Sie auf dieser Website macht eintragen. Damit dieser Text hier möglichst lang ist werde ich einfach irgend ein Scheiss labern. Eigentlich will ich ihn auch nicht wirklich möglichst lang machen sondern
nur so lang, wie auch ungefähr eine Vorstellung bzw Beschreibung sein würde. Ich würde mal sagen, diese länge an Text sollte genügen.
</p>
<div class="push"></div>
</div>
</main>
<footer>
<div class="foot_wrapper">
<a class="foot_item" href="https://www.instagram.com/el_pastelazo_/?hl=de" title="#el_pastelazo_"><i class="fab fa-instagram"></i></a>
<a class="foot_item" href="https://github.com/" title="Probably Insta"><i class="fa fa-github"></i></a>
<a class="foot_item" href="https://www.pinterest.de/" title="Pinterest"><i class="fa fa-pinterest-p"></i></a>
<a class="foot_item" href="https://www.gmx.ch/" title="Mail"><i class="fa fa-envelope-o"></i></a>
</div>
</footer>
</div>
Adding display:flex style to an HTML element by default make its children appear side by side unless you explicitly add flex-direction: column;.
After Looking at your html carefully I see that you have added display:flex to head_flex_container which has only one child i.e head_titel_container.
You could add display:flex property to head_titel_container because it has two children that needs to appear side by side.
<div class="head_titel_container">
<div class="flex_logo"><img src="pictures/Logo.jpeg" alt="Logo" title="El Pastelazo" id="logo"></div>
<div class="flex_titel"><h1>El Pastelazo</h1></div>
</div>
.head_titel_container {
display: flex;
}
Adding display: flex style to .head_titel_container in your css file should make them appear side by side.
Let me know if you have any problems with this approach.
Did you want something like this?
/*flex items*/
.head_titel_container{
border: 5px solid blue;
max-height: 22rem;
width: 50%;
min-width: 50%;
position: relative;
display: inline-block;
}
.flex_titel{
position: absolute;
left:800px;
top:-10px;
width: 78%;
box-sizing: content-box;
border: 5px solid black;
display: inline-block;
}
By the way, there's this website called JSFiddle where you can post your code for a quick demo. Might be useful in the future.
I have an issue in CSS while trying to fade in some elements in CSS.
I would like to show with a fade in effect some elements in my image right after the rotate transition but it doesn't work.
I did a jsfiddle and you can activate the effect with an hover on the image :
https://jsfiddle.net/egfjp36h/
Here's my HTML code :
<div class="flip-box">
<div class="fut-player-card card-display">
<div class="fut-front">
<div class="player-card-top player-card-top-color">
<div class="player-master-info">
<div class="player-rating">
<span>97</span>
</div>
<div class="player-position">
<span>RW</span>
</div>
<div class="player-nation">
<img src="https://selimdoyranli.com/cdn/fut_card/img/argentina.svg" alt="Argentina" draggable="false">
</div>
<div class="player-club">
<img src="https://selimdoyranli.com/cdn/fut_card/img/barcelona.svg" alt="Barcelona" draggable="false">
</div>
</div>
<div class="player-picture">
<img src="https://selimdoyranli.com/cdn/fut_card/img/messi.png" alt="Messi" draggable="false">
</div>
</div>
<div class="player-card-bottom">
<div class="player-info player-info-color">
<div class="player-name player-name-border"><span>MESSI</span></div>
<div class="player-features">
<div class="player-features-col player-features-col-border">
<span>
<div class="player-feature-value">97</div>
<div class="player-feature-title">RDV</div>
</span>
<span>
<div class="player-feature-value">95</div>
<div class="player-feature-title">CTR</div>
</span>
<span>
<div class="player-feature-value">94</div>
<div class="player-feature-title">TRANSF</div>
</span>
</div>
<div class="player-features-col player-features-col-border">
<span>
<div class="player-feature-value">99K€</div>
<div class="player-feature-title">CA</div>
</span>
<span>
<div class="player-feature-value">35</div>
<div class="player-feature-title">DEF</div>
</span>
<span>
<div class="player-feature-value">68</div>
<div class="player-feature-title">PHY</div>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
And my CSS :
.fut-player-card{
position: relative;
width:300px;
height:485px;
background-position: center center;
background-size:100% 100%;
background-repeat: no-repeat;
padding:5.9rem 0;
z-index: 2;
transition: 200ms ease-in;
margin-left: auto;
margin-right: auto;
}
.card-display{
background-image: url(https://selimdoyranli.com/cdn/fut_card/img/card_bg.png);
}
.card-display2{
background-image: url("img/fut/fut1.png");
}
.card-display3{
background-image: url("img/fut/fut2.png");
}
.card-display4{
background-image: url("img/fut/fut3.png");
}
.player-card-top{
position: relative;
display: flex;
padding: 0 3.5rem;
}
.player-master-info{
position: absolute;
line-height: 3.2rem;
font-weight: 300;
padding: 3rem 0;
text-transform: uppercase;
}
.player-rating{
font-size:3rem;
}
.player-position{
font-size: 2.2rem;
}
.player-nation{
display: block;
width:3rem;
height:25px;
margin: 0.5rem 0;
}
.player-nation img{
width:100%;
height: 100%;
object-fit: contain;
}
.player-club{
display: block;
width:3.1rem;
height:40px;
}
.player-club img{
width:100%;
height: 100%;
object-fit: contain;
}
.player-picture{
width:200px;
height:200px;
margin: 0 auto;
overflow: hidden;
}
.player-picture img{
width:100%;
height:100%;
object-fit: contain;
position: relative;
right: -1.5rem;
bottom: 0;
}
.player-extra{
position: absolute;
right:0;
bottom: -0.5rem;
overflow: hidden;
font-size:1rem;
font-weight: 700;
text-transform: uppercase;
width:100%;
height:2rem;
padding:0 1.5rem;
text-align: right;
background:none;
}
.player-extra span{
margin-left: 0.6rem;
text-shadow:2px 2px #333;
}
.player-card-bottom{
position: relative;
}
.player-info{
display: block;
padding:1rem 0;
width:90%;
margin:0 auto;
height: auto;
position: relative;
z-index: 2;
}
.player-info-color, .player-card-top-color{
color:#e9cc74;
}
.player-info-color2, .player-card-top-color2{
color:#130d40;
}
.player-name{
width:100%;
display: block;
text-align: center;
font-size:2.2rem;
text-transform: uppercase;
padding-bottom: 0.3rem;
overflow: hidden;
}
.player-name-border{
border-bottom: 2px solid;
border-color: rgba(233,204,116, 0.1);
}
.player-name-border2{
border-bottom: 2px solid;
border-color: rgba(13, 33, 74, 0.2);
}
.player-name span{
display: block;
text-shadow:2px 2px #111;
}
.player-name2 span{
display: block;
text-shadow:2px 2px #fff;
}
.player-features{
margin: 1rem auto;
display: flex;
justify-content: center;
}
.player-features-col{
border-right: 2px solid;
padding: 0 3rem;
}
.player-features-col-border{
border-color: rgba(233,204,116, 0.1);
}
.player-features-col-border2{
border-color: rgba(13,33,74, 0.2);
}
.player-features-col span{
display: flex;
font-size: 2rem;
text-transform: uppercase;
}
.player-feature-value{
margin-right: 1rem;
font-weight: 700;
}
.player-feature-title{
font-weight: 300;
}
.player-features-col:last-child{
border:0;
}
.flip-box {
perspective: 1000px;
display: inline-block;
}
.fut-player-card{
position: relative;
text-align: center;
transition: transform 0.8s;
transform-style: preserve-3d;
}
.flip-box:hover .fut-player-card{
transform: rotateY(180deg);
}
.flip-box:hover .fut-front{
filter: alpha(opacity=100);
opacity:1;
}
.fut-front{
position: absolute;
}
.fut-front{
transition: opacity 0.8s linear 1.2s;
filter: alpha(opacity=0);
opacity: 0;
}
I thought it was OK with those elements but the transition is effective when the mouse leave the image and not when the mouse comes over the image :
.flip-box:hover .fut-front{
filter: alpha(opacity=100);
opacity:1;
}
.fut-front{
transition: opacity 0.8s linear 1.2s;
filter: alpha(opacity=0);
opacity: 0;
}
EDIT : It works on Firefox but not on Chrome
You can select the element with javascript and add:
addEventListener("mouseenter", function( event ) {
//change opacity here
})
I'm working on a Meteor app, using StylusGrid (a flexbox grid) for my layout and Transformicons for my menu button.
How can I vertically align this h1?
HTML:
<header class="toolbar">
<section>
<div class="menu-button">
<button type="button" class="tcon tcon-menu--xcross" aria-label="toggle menu">
<span class="tcon-menu__lines" aria-hidden="true"></span>
<span class="tcon-visuallyhidden">toggle menu</span>
</button>
</div>
<h1>MyApp</h1>
</section>
<section class="links">
Help
</section>
</header>
CSS on jsFiddle.
I want the H1 tag to be in line with the button in, vertically centered.
I set the flexbox grid rules so that it would vertically center the contents, which is working fine for the menu button and help link.
But the H1 is out of place. How can I fix it?
Add to h1 CSS:
vertical-align: middle;
Works for me: JSFiddle.
Snippet:
.toolbar {
display: flex;
flex-direction: row;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
background-color: #fff;
}
.toolbar section {
flex-basis: calc(100% * 0.5 - 1.25rem);
-ms-flex-preferred-size: calc(100% * 0.5 - 1.25rem);
margin: 0.625rem;
-ms-flex-item-align: center;
align-self: center;
}
.toolbar .menu-button {
display: inline-block;
}
.toolbar h1 {
display: inline-block;
margin: 0px;
padding: 0px;
vertical-align: middle;
}
.toolbar .links {
text-align: right;
}
.tcon {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
border: none;
cursor: pointer;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
height: 40px;
transition: 0.3s;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
width: 40px;
background: transparent;
outline: none;
-webkit-tap-highlight-color: transparent;
-webkit-tap-highlight-color: transparent;
}
.tcon > * {
display: block;
}
.tcon:hover,
.tcon:focus {
outline: none;
}
.tcon::-moz-focus-inner {
border: 0;
}
.tcon-menu__lines {
display: inline-block;
height: 5.71429px;
width: 40px;
border-radius: 2.85714px;
transition: 0.3s;
background: black;
position: relative;
}
.tcon-menu__lines::before,
.tcon-menu__lines::after {
display: inline-block;
height: 5.71429px;
width: 40px;
border-radius: 2.85714px;
transition: 0.3s;
background: black;
content: '';
position: absolute;
left: 0;
-webkit-transform-origin: 2.85714px center;
transform-origin: 2.85714px center;
width: 100%;
}
.tcon-menu__lines::before {
top: 10px;
}
.tcon-menu__lines::after {
top: -10px;
}
.tcon-transform .tcon-menu__lines {
-webkit-transform: scale3d(0.8, 0.8, 0.8);
transform: scale3d(0.8, 0.8, 0.8);
}
.tcon-menu--xcross {
width: auto;
}
.tcon-menu--xcross.tcon-transform .tcon-menu__lines {
background: transparent;
}
.tcon-menu--xcross.tcon-transform .tcon-menu__lines::before,
.tcon-menu--xcross.tcon-transform .tcon-menu__lines::after {
-webkit-transform-origin: 50% 50%;
transform-origin: 50% 50%;
top: 0;
width: 40px;
}
.tcon-menu--xcross.tcon-transform .tcon-menu__lines::before {
-webkit-transform: rotate3d(0, 0, 1, 45deg);
transform: rotate3d(0, 0, 1, 45deg);
}
.tcon-menu--xcross.tcon-transform .tcon-menu__lines::after {
-webkit-transform: rotate3d(0, 0, 1, -45deg);
transform: rotate3d(0, 0, 1, -45deg);
}
.tcon-visuallyhidden {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
.tcon-visuallyhidden:active,
.tcon-visuallyhidden:focus {
clip: auto;
height: auto;
margin: 0;
overflow: visible;
position: static;
width: auto;
}
<header class="toolbar">
<section>
<div class="menu-button">
<button type="button" class="tcon tcon-menu--xcross" aria-label="toggle menu">
<span class="tcon-menu__lines" aria-hidden="true"></span>
<span class="tcon-visuallyhidden">toggle menu</span>
</button>
</div>
<h1>MyApp</h1>
</section>
<section class="links">
Help
</section>
</header>