I am trying to get a scale effect when I hover over a thumb, as in this Codepen example (first thumb, the Lily effect):
http://codepen.io/intermedion/pen/BQVJEx
I modified the above example to remove the figure/figcaption, and I used a flexbox layout for the thumb grid, see this pen:
http://codepen.io/intermedion/pen/dOKrWQ?editors=1100
<!-- HTML -->
<div class="wrap">
<div class="row">
<div>
<a href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/jeremiah-wilson-1.jpg">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/jeremiah-wilson-1.jpg">
</a>
</div>
<div>
<a href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/jeremiah-wilson-3.jpg">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/jeremiah-wilson-3.jpg">
</a>
</div>
</div>
</div>
/* CSS */
.row {
display: flex;
flex-flow: row wrap;
padding: 0 5px;
font-size: 0;
}
.row div {
flex: auto;
width: 160px;
margin: 6px 12px;
}
.row div img {
width: 100%;
height: auto;
}
/*** EFFECTS ***/
.row img {
position: relative;
display: block;
min-height: 100%;
max-width: 100%;
}
.row img {
-webkit-transition: opacity 0.35s, -webkit-transform 0.35s;
transition: opacity 0.35s, transform 0.35s;
}
.row:hover img {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
-webkit-transform: scale(1.15);
transform: scale(1.15);
}
I tried various options, including setting sizes on the thumbs, adding figure/figcaption - the thumbs scale, but over and beyond the thumbnail size, which is not what I want.
I am starting to suspect that it may be the flexbox layout that is causing the scaling beyond the rendered thumb size, but I am not sure.
Is there any way to do the scaling within the rendered thumb with a flexbox layout?
I think you forgot overflow:hidden for the div:
.row div {
flex: auto;
width: 160px;
margin: 6px 12px;
overflow: hidden;
}
html {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
ul {
list-style-type: none;
}
a:link { text-decoration: none; }
a:visited { text-decoration: none; }
a:hover { text-decoration: none;}
html {
background: #2b303b;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
/*** LAYOUT ***/
.wrap {
max-width: 660px;
margin: 1.5em auto 1em auto;
padding: 10px 10px;
background: #2e333f;
background-color: rgba(32, 38, 52, 0.6);
background: #242B3A;
font-family: "PT Sans", "Helvetica Neue", Arial, sans-serif;
font-size: 100%;
color: rgba(127, 133, 147, 0.8);
border-radius: 5px;
-webkit-border-radius: 0px 0px 5px 5px;
-moz-border-radius: 0px 0px 5px 5px;
}
/*** GRID ***/
.row {
display: flex;
flex-flow: row wrap;
padding: 0 5px;
font-size: 0;
}
.row div {
flex: auto;
width: 160px;
margin: 6px 12px;
overflow: hidden;
}
.row div img {
width: 100%;
height: auto;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
/*** EFFECTS ***/
.row img {
position: relative;
display: block;
min-height: 100%;
max-width: 100%;
}
.row img {
-webkit-transition: opacity 0.35s, -webkit-transform 0.35s;
transition: opacity 0.35s, transform 0.35s;
}
.row div:hover img {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
-webkit-transform: scale(1.15);
transform: scale(1.15);
}
/*** CAPTIONS ***/
/*
.grid figure {
position: relative;
float: left;
overflow: hidden;
margin: 10px 1%;
min-width: 300px;
max-width: 480px;
max-height: 360px;
width: 48%;
background: #3085a3;
text-align: center;
cursor: pointer;
}
*/
/*
.grid figure img {
position: relative;
display: block;
min-height: 100%;
max-width: 100%;
opacity: 0.8;
}
*/
<div class="wrap">
<div class="row">
<div>
<a href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/jeremiah-wilson-1.jpg">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/jeremiah-wilson-1.jpg">
</a>
</div>
<div>
<a href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/jeremiah-wilson-3.jpg">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/jeremiah-wilson-3.jpg">
</a>
</div>
</div>
</div>
Related
So I've got a problem where I've got two tabs (https://codepen.io/databell/pen/LYjxvyx) where the first tab opens up content and the second opens up a modal.
Now to be clear, those functions work. That's not the issue. So for those purposes, I deleted those out of my example. Focusing on CSS here.
My problem is I want plus + symbols to appear to the right side of each tab (really a div) and instead one tab has the symbol to the far right of the container, even though the tab is set to width 100%. So I'm stumped as to what the problem is.
This is meant to go into a Shopify store using the Dawn theme, so I'm using their elements here to create this interface.
Here's the code.
<div id="info-additions" class="product__accordion accordion info-additions-content" >
<details>
<summary>
<div class="summary__title info-additions-tab g-flex">
<h2 class="h4 accordion__title t-body benefits">
Tab One
<span></span>
</h2>
</div>
<div class="summary__title info-additions-tab g-flex">
<modal-opener class="product-popup-modal__opener no-js-hidden" data-modal="#PopupModal-ingr">
<button id="ProductPopup-ingr" class="summary__title t-body ingredients" type="button" aria-haspopup="dialog" data-additions-tab="ingredients">
<h2 class="h4 accordion__title">
Tab Two
<span></span>
</h2>
</button>
</modal-opener>
</div>
</summary>
<div class="accordion__content rte">
<p>Content</p>
</div>
</details>
</div>
CSS:
body {
font-size: 1.6rem;
}
*, ::before, ::after {
box-sizing: inherit;
}
.h0, .h1, .h2, .h3, .h4, .h5, h1, h2, h3, h4, h5 {
letter-spacing: .06rem;
line-height: 1.3;
}
.h4, h4 {
font-size: 1.6rem;
}
.grid {
list-style: none;
}
.g-flex {
display: flex;
display: -webkit-flex;
flex-wrap: wrap;
-webkit-flex-wrap: wrap;
}
.accordion summary {
cursor: pointer;
display: flex;
position: relative;
list-style: none;
line-height: 1;
padding: 1.5rem 0;
}
.accordion__title {
display: inline-block;
max-width: calc(100% - 6rem);
min-height: 1.6rem;
margin: 0;
word-break: break-word;
}
details > * {
box-sizing: border-box;
}
.accordion__title {
word-break: break-word;
}
.accordion .summary__title {
display: flex;
flex: 1;
}
#info-additions {
clear: both;
height: auto;
margin: 15px 0 0;
border-top: 2px solid;
border-bottom: 2px solid;
width: 100%;
}
.info-additions-content {
position: relative;
height: 0;
transition: .6s var(--a-cubic-1);
}
.info-additions-tab {
justify-content: space-between;
}
.info-additions-tab span {
display: block;
position: absolute;
width: 18px;
height: 18px;
top: 13px;
right: 2rem;
}
.info-additions-tab button {
position: relative;
padding: 16px 0!important;
line-height: 1;
font-weight: 500;
text-align: left;
}
.info-additions-tab button.benefits {
width: 50%;
}
.info-additions-tab .product-popup-modal__opener {
width: 100% !important;
}
.info-additions-tab button.ingredients {
width: 100%;
}
.info-additions-tab span {
display: block;
position: absolute;
width: 18px;
height: 18px;
top: 13px;
right: 2rem;
}
.info-additions-tab span:before,
.info-additions-tab span:after {
content: '';
display: block;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%) rotate(90deg);
transform: translate(-50%, -50%) rotate(90deg);
width: 2px;
height: 18px;
background-color: black;
transition: 0.3s;
}
.info-additions-tab button:not(.active) span:after {
-webkit-transform: translate(-50%, -50%) rotate(180deg);
transform: translate(-50%, -50%) rotate(180deg);
}
.info-additions-content {
position: relative;
height: 0;
transition: 0.6s var(--a-cubic-1);
}
.info-additions-content [data-additions-content] {
position: absolute;
width: 100%;
top: 0;
left: 0;
padding: 5px 0 20px;
opacity: 0;
pointer-events: none;
transition: 0.3s 0s;
}
.info-additions-content [data-additions-content].active {
opacity: 1;
pointer-events: auto;
transition-delay: 0.4s;
}
#info-additions button {
padding: 0;
background: transparent;
color: inherit;
cursor: pointer;
border: 0;
border-radius: 0;
outline: none;
-webkit-appearance: none;
-moz-appearance: none;
-o-appearance: none;
appearance: none;
transition: 0.2s;
}
if you want an absolute element like + to stay in the parent element you have to set the position of the parent to "relative".
you have two problems. summary__title doesn't have a position so + doesn't stay in it .
for the second tab, your modal button has a relative position that makes the + stay inside of it instead of the summary__title.
.accordion .summary__title {
...
position: relative; // add position
}
#info-additions button {
...
position: unset; // unset the position of the button
}
I have a problem that my transition does not get applied on an absolute positon child div.
Here is my codepen:
https://codepen.io/Data-Mastery/pen/oNvRdGv
On line 213 (&:hover .image) in the SASS file I want to scale the image and also set a filter, which works fine, but the transition-duration does not get applied.
If I just apply the hover statement on the parent element and not the image, the transition works fine. What is wrong here, can anyone help me?
Just add a transition to the .image class (or to the hover function, whatever you want to achieve)
&:hover .image {
transform: scale(1.1);
filter: grayscale(50%);
transition: your parameter;
}
Add transition property to the
& .image {
position: absolute;
top: 0;
left: 0;
width: 100%;
margin-bottom: 1.5rem;
transition:0.5s;
}
This will work for you
Why man , it works see this:-
#import url("https://fonts.googleapis.com/css?family=Open+Sans&display=swap");
#keyframes moveInLeft {
0% {
transform: translateX(-200px);
opacity: 0;
}
80% {
transform: translateX(10px);
opacity: 0.8;
}
100% {
transform: translateX(0px);
opacity: 1;
}
}
#keyframes moveInRight {
0% {
transform: translateX(200px);
opacity: 0;
}
80% {
transform: translateX(-10px);
opacity: 0.8;
}
100% {
transform: translateX(0px);
opacity: 1;
}
}
#keyframes moveInBottom {
0% {
transform: translateY(100px);
opacity: 0;
}
100% {
transform: translateY(0px);
opacity: 1;
}
}
.leftanimation {
animation: moveInLeft 1.2s forwards;
}
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
font-family: "Open Sans", sans-serif;
line-height: 1.4rem;
}
li {
list-style: none;
}
a {
text-decoration: none;
}
p {
margin: 0.75rem;
}
.l-heading-light {
font-size: 3rem;
color: white;
padding-top: 3rem;
padding-bottom: 1rem;
}
.l-heading-dark {
font-size: 3rem;
color: #c2453b;
padding-top: 3rem;
padding-bottom: 1rem;
}
.primary-btn {
display: inline-block;
background: #c2453b;
color: #fff;
padding: 0.5rem 2rem;
font-size: 1.25rem;
border-radius: 20px;
transition: all 0.3s ease-in;
}
.primary-btn:hover {
background: #fff;
color: #c2453b;
transform: translateY(-3px);
box-shadow: 0 10px 15px rgba(0, 0, 0, 0.5);
}
.primary-btn:active {
transform: translateY(-1px);
box-shadow: 0 5px 10px rgba(0, 0, 0, 0.5);
}
.navbar {
display: flex;
z-index: 1;
justify-content: space-between;
align-items: center;
width: 100%;
position: fixed;
top: 0;
padding: 1rem;
background: #333;
color: #fff;
}
.navbar__nav {
display: flex;
justify-content: space-between;
}
.navbar__nav li a {
color: #fff;
padding: 0.75rem;
margin: 0 0.25rem;
}
.navbar__nav li a:hover {
background: #fff;
border-radius: 5px;
color: #333;
}
.showcase {
background-image: linear-gradient(to bottom right, rgba(194, 69, 59, 0.4), rgba(178, 86, 65, 0.4)), url("https://thumbs.dreamstime.com/z/hiking-forest-man-morning-mist-travel-concept-45457025.jpg");
background-size: cover;
background-position: top;
height: 100vh;
position: relative;
}
.showcase__content {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
text-transform: uppercase;
}
.showcase__content p {
color: white;
font-size: 1.2rem;
margin-bottom: 1rem;
animation: moveInRight 1.2s forwards;
}
.showcase__content a {
animation: moveInBottom 1.2s 0.8s linear backwards;
}
#tours {
text-align: center;
background: #f7f7f7;
}
#tours .container {
width: 100%;
height: 100%;
margin: 0 auto;
display: block;
max-width: 1200px;
justify-content: space-between;
display: flex;
color: #fff;
}
#tours .container .card {
position: relative;
height: 35rem;
width: 20rem;
margin: 2rem 1rem;
padding: 0;
background: #b25641;
box-shadow: 0 10px 15px rgba(0, 0, 0, 0.4);
transition: all 0.4s ease-in-out;
overflow: hidden;
}
#tours .container .card:hover .image {
transform: scale(1.1);
filter: grayscale(100%);
transition-duration: 0.5s;
}
#tours .container .card .image {
position: absolute;
top: 0;
left: 0;
width: 100%;
margin-bottom: 1.5rem;
}
#tours .container .card__content {
position: absolute;
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
margin-top: 15rem;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link rel="stylesheet" href="css/style.css" />
<title>Malamar Hotels</title>
</head>
<body>
<nav class="navbar">
<h1 class="navbar__logo">
Malamar
</h1>
<ul class="navbar__nav">
<li>Home</li>
<li>Tours</li>
<li>Contact</li>
</ul>
</nav>
<header class="showcase">
<div class="showcase__content">
<h1 class="l-heading-light leftanimation">
Hiking this fall
</h1>
<p>
Book the best hikings tours for this fall in beautiful areas across
europe
</p>
See our tours
</div>
</header>
<section id="tours">
<h1 class="l-heading-dark">Our best offers</h1>
<div class="container">
<div class="card">
<img src="https://thumbs.dreamstime.com/z/hiking-forest-man-morning-mist-travel-concept-45457025.jpg" alt="Hi" class="image" />
<div class="card__content">
<h1>Hiking</h1>
<p>2-day tour</p>
Book now!
</div>
</div>
<div class="card">
<img src="https://thumbs.dreamstime.com/z/hiking-forest-man-morning-mist-travel-concept-45457025.jpg" alt="Hi" class="image" />
<div class="card__content">
<h1>Rafting tour</h1>
<p>3-day tour</p>
Book now!
</div>
</div>
<div class="card">
<img src="https://thumbs.dreamstime.com/z/hiking-forest-man-morning-mist-travel-concept-45457025.jpg" alt="Hi" class="image" />
<div class="card__content">
<h1>Mountainbiking</h1>
<p>5-day tour</p>
Book now!
</div>
</div>
</div>
</section>
</body>
</html>
I have a nav menu that slides into view from the right side of the screen once the hamburger icon is clicked. It works correctly in Chrome and Firefox - basically when triggered it takes up 50vw and fills the screen vertically. However in Safari it seems as if the z-index is not behaving correctly because the menu appears to be buried underneath the other elements of the page and ultimately not visible at all.
I've tried adjusting the z-index of a variety of elements to see if that was the simple fix and it has proven to be something more complicated. I have read a few forums that suggested including "-webkit-transform: translate3d(0, 0, 0);" but unfortunately that doesnt seem to work either. If you inspect the sidebarMenu element in Safari you can see that it is in the correct position, it is just not rendering correctly.
Below is a link to a codepen - I am missing some styles on this so the positioning isnt quite right but it effectively shows the general functionality that I am looking for. When opening this link in Safari you can see that the sidebarMenu does not appear to be rendering at all.
https://codepen.io/rmann20/pen/EzbeaV
sample code:
<div class="header">
<hr class="nav-rule">
<div class="nav-container">
<div class="nav-logo-container">
<img class="nav-logo" src="images/nav_logo.png">
<input type="checkbox" class="openSidebarMenu" id="openSidebarMenu">
<label for="openSidebarMenu" class="sidebarIconToggle">
<div class="spinner diagonal part-1"></div>
<div class="spinner horizontal"></div>
<div class="spinner diagonal part-2"></div>
</label>
<div id="sidebarMenu">
<ul class="sidebarMenuInner">
<li>Rooms & Suites</li>
<li>Packages</li>
<li>Eat & Drink</li>
<li>Meetings & Events</li>
<li>Weddings</li>
<li>Experiences</li>
<li>Neighborhood</li>
</ul>
<ul class="sidebarMenuInnerSecondary">
<li>ABOUT</li>
<li>HISTORY</li>
<li>GALLERY</li>
<li>PRESS</li>
<li>CONTACT</li>
<li>CAREERS</li>
</ul>
</div>
</div>
<img class="nav-tagline" src="images/nav_tagline.png">
<a class="nav-reservation-button" href="" target="_blank">RESERVE NOW</a>
</div>
<hr class="nav-rule">
</div>
.header {
display: flex!important;
flex-wrap: wrap;
margin: 0;
padding: 10px 0 10px 0;
width: 100%;
max-width: 100%;
box-shadow: none;
background-color: #f5f4f0;
position: fixed;
height: 110px!important;
overflow: hidden;
z-index: 10;
justify-content: space-between!important;
}
.nav-container {
display: flex;
height: 79px;
width: 100%;
align-items: center;
justify-content: space-between;
}
.main {
margin: 0 auto;
display: block;
height: 100%;
margin-top: 60px;
}
.mainInner{
display: table;
height: 100%;
width: 100%;
text-align: center;
}
.mainInner div{
display:table-cell;
vertical-align: middle;
font-size: 3em;
font-weight: bold;
letter-spacing: 1.25px;
}
#sidebarMenu {
min-height: 100%;
position: fixed;
right: 0;
width: 50vw;
margin-top: 42px;
transform: translateX(50vw);
transition: transform 250ms ease-in-out;
background-color: #f5f4f0;
overflow: scroll;
padding: 60px 60px 60px 60px;
z-index: 10000!important;
}
.sidebarMenuInner{
margin:8px;
padding:0;
border-top: 1px solid rgba(255, 255, 255, 0.10);
list-style: none;
}
.sidebarMenuInner li a{
color: #3d3936;
font-family: 'QuincyCF-ExtraBold', Helvetica, Arial, Sans-Serif;
font-weight: normal;
font-style: normal;
cursor: pointer;
text-decoration: none;
font-size: 3.2em;
}
.sidebarMenuInnerSecondary {
margin-top: 60px;
list-style: none;
}
.sidebarMenuInnerSecondary li {
margin-top: 14px;
margin-bottom: 14px;
}
input[type="checkbox"]:checked ~ #sidebarMenu {
transform: translateX(0);
}
input[type=checkbox] {
transition: all 0.3s;
box-sizing: border-box;
display: none;
}
.sidebarIconToggle {
transition: all 0.3s;
box-sizing: border-box;
cursor: pointer;
position: absolute;
z-index: 99;
height: 100%;
width: 100%;
top: 48px;
right: 40px;
height: 28px;
width: 28px;
}
.spinner {
transition: all 0.3s;
box-sizing: border-box;
position: absolute;
height: 3px;
width: 100%;
background-color: #3d3936;
}
.horizontal {
transition: all 0.3s;
box-sizing: border-box;
position: relative;
float: left;
margin-top: 3px;
}
.diagonal.part-1 {
position: relative;
transition: all 0.3s;
box-sizing: border-box;
float: left;
}
.diagonal.part-2 {
transition: all 0.3s;
box-sizing: border-box;
position: relative;
float: left;
margin-top: 3px;
}
input[type=checkbox]:checked ~ .sidebarIconToggle > .horizontal {
transition: all 0.3s;
box-sizing: border-box;
opacity: 0;
}
input[type=checkbox]:checked ~ .sidebarIconToggle > .diagonal.part-1 {
transition: all 0.3s;
box-sizing: border-box;
transform: rotate(135deg);
margin-top: 8px;
}
input[type=checkbox]:checked ~ .sidebarIconToggle > .diagonal.part-2 {
transition: all 0.3s;
box-sizing: border-box;
transform: rotate(-135deg);
margin-top: -9px;
}
.nav-logo-container {
width: 260px;
margin-left: 40px;
}
I dont get any errors and everything else seems to be working correctly, can't figure out why it's not showing at this point. Any help would be greatly appreciated!
I'm writing a code for the chat of my stream, but i got some problems... i want to rotate only the border of the chat box without move the text or the background. how can i do this? i have already read some post but did not solve my problem. i want to do something like that chat.
i use the StreamLabs.
English is not my mother tongue; please excuse any errors on my part.
I'm a beginner at the front end and these issues are taking away my peace.
#import url(https://fonts.googleapis.com/css?family=Open+Sans:600,700);
body {
background: $background_color;
color: $text_color;
}
html, body {
height: 600%;
overflow: hidden;
transform: translate(0px, -10px);
}
#log {
font: 90;
font-family: 'Montserrat', sans-serif;
position: absolute;
bottom: 0;
left: 0;
width: 60%;
box-sizing: border-box;
overflow: hidden;
padding: 10px 16px;
padding-top: 100px;
}
#log>div {
margin-bottom: 45px;
background: rgba(255, 255, 255, 0.1);
padding: 5px 10px 10px;
animation: fadeInDown .3s ease forwards, fadeOut 0.5s ease {message_hide_delay} forwards;
-webkit-animation: fadeInDown .3s ease forwards, fadeOut 0.5s ease {message_hide_delay} forwards;
border-radius: 8px;
}
#log>div.deleted {
visibility: hidden;
}
.meta {
display: table;
line-height: em;
transform: translate(-20px,-30px);
border-radius: 0px 05px 05px 05px;
border: 10px solid #ffd600;
background: #ffd600;
margin-bottom: -22px;
font-weight: 800;
}
.message {
word-wrap: break-word;
display: block;
padding-left: 6px;
line-height: em;
color:white;]
}
.name {
color: Black;
font-size: em;
text-transform: initial;
font-weight: 600;
}
.colon {
display: none;
}
.badge {
float: left;
padding-left: 2px;
padding-right: 7px;
padding-top: 2px;
height: 0.8em;
}
#log .emote {
background-repeat: no-repeat;
background-position: center;
padding: 0.1em;
background-size: contain;
}
#log .emote img {
display: inline-block;
height: 1em;
opacity: 0;
vertical-align: top;
}
<!-- item will be appened to this layout -->
<div id="log" class="sl__chat__layout">
</div>
<!-- chat item -->
<link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Merriweather" rel="stylesheet">
<script type="text/template" id="chatlist_item">
<div data-from="{from}" data-id="{messageId}">
<span class="meta" style="color: {color}">
<span class="badges">
</span>
<span class="name">{from}</span>
</span>
<span class="message">
{message}
</span>
</div>
</script>
You can add a new element to your html and style it to look like that border, or style a pseudo element like ::before or ::after to give you that look.
.tilted-border {
margin: 10px;
background: purple;
border-radius: 10px;
width: 200px;
height: 100px;
position: relative;
padding: 0;
}
.tilted-border:after {
content: '';
display: block;
position: absolute;
top: -5px;
left: -5px;
width: 100%;
height: 100%;
border: 5px solid red;
border-radius: 10px;
transform: rotate( 5deg);
pointer-events: none;
}
<div class="tilted-border"></div>
What you're trying to do is not possible. You cannot move the border of a div independently of the div and its content.
What you'll need to do is create bother div within the first div. Set the container div to position: relative and then absolutely position the new inner div to the edges of the container like so: position: absolute; top: 0; bottom: 0; left: 0; right: 0;. Then you can animate the border of the inner div while the content still sits within the container div free of the transform.
So I have the hover state figured out. I'd like to keep the card at it's translated stated once I click on it though. I've tried using pseudo class :focus and :active but it didn't work. Or I'm just not putting the right values in.
$('.wrapper').on('click', function() {
$(this).addClass('active');
});
.wrapper:hover {
transform: translateY(5px);
}
.wrapper:active {
transform: translateY(5px);
position: fixed;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="wrapper">
<div class="paper">
<img src="https://www.jbhifi.com.au/FileLibrary/ProductResources/Images/216422-M-LO.jpg">
<div class="poster">
<h2>Featured</h2>
<h1>Big Baby Swing</h1>
<p>Does he look like hes stupid. Did he drive well? No. Then is he stupid? He's a good kid that's like the devil behind a wheel. That's all you need to know about him..</p>
More
</div>
</div>
<div class="space"></div>
</div>
codepen to my question
You assign a active class on click so .wrapper.active instead of .wrapper:active should work
You missed jquery cdn and add some css following if you need to get back use toggleClass.
.wrapper.active{
transform: translateY(5px);
}
.wrapper.active div a.button{
width:auto;
font-size: 0.8rem;
background-color: #29426d;
box-shadow: none;
}
$('.wrapper').on('click', function() {
$(this).addClass('active');
// You can use here toggleClass also
});
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
background: #2c3e50;
font-family: 'Montserrat', sans-serif;
font-size: 14px;
}
/* this centers the card in the middle of any browser */
body {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
align-items: center;
align-content: center;
background-color: #D7D7DD;
}
/* You can rename this .wrapperCard or what ever you may have used. The important thing to notice is the z-index relative to the .papaer div in order for this to work. In the HTML document .space which contains the gradient at the bottom is out side of .paper that holds the information. */
.wrapper {
margin: 0;
padding: 0;
height: auto;
width: auto;
transition: 1s ease;
cursor: pointer;
z-index: 98;
}
.wrapper:hover{
transform: translateY(5px);
}
.wrapper.active{
transform: translateY(5px);
}
.wrapper.active div a.button{
width:auto;
font-size: 0.8rem;
background-color: #29426d;
box-shadow: none;
}
.wrapper:hover div a.button{
width:auto;
font-size: 0.8rem;
background-color: #29426d;
box-shadow: none;
}
/* This calls onto the div.paper on hover and looks for div.space, if you take a way div.space your gradient will not longer dissapear on hover. */
.wrapper:hover div.space{
transform: translateY(-7px);
z-index:-1;
}
/* This is the div that contains all of the informoation, to be noted. The div is set to a specific height of 41, it basically reaches to the bottom of the MORE button. The reason being is so I can hide the gradient which is the div space, placed all the way at the bottom with a z-index of -1. If you take out the height in div.paper you will see why I made the card a particular size, so keep that in mind when you are transfering the gradient code onto the cards for NASCA. */
.paper{
font-family: 'Titilium Web', sans-serif;
display: flex;
flex-wrap: wrap;
align-items: center;
align-content: center;
margin: 0 auto;
padding: 0;
max-width: 300px;
min-width: 300px;
background: white;
text-align: justify;
z-index: 99;
}
a.image{
flex: 1;
text-align: none;
font-size: none;
text-decoration: none;
color:none;
transition: none;
padding:0;
margin: 0;
height: auto;
}
a.image:hover{
color:none;
border-bottom:none;
text-align: none;
box-shadow: none;
transform: none;
}
.poster{
flex: 1;
height: auto;
}
h2{
flex: 1;
font-size: .55rem;
color: #A0A6AB;
letter-spacing: 2px;
text-transform: uppercase;
text-align: center;
font-family: $sans-serif;
font-weight: 500;
margin-bottom: 10px;
}
h1{
flex: 1;
display: flex;
justify-content: center;
margin-top:1rem;
font-weight:bolder;
letter-spacing: normal;
font-kerning: 1rem;
transition: 0.5s ease;
color: #29426d;
}
h1:hover{
transform: translateX(2px);
}
p{
flex: 1;
padding: 1rem 1rem;
color:#333333;
}
a.button{
position: relative;
display: flex;
justify-content: center;
cursor: pointer;
text-transform: uppercase;
text-decoration: none;
font-size: 0.8rem;
line-height: 20px;
letter-spacing: .06rem;
font-weight: bold;
color: white;
background: #e44d6e;
margin: 0 auto;
padding: 0.5rem 1rem;
width: auto;
transition: 1s ease;
}
/* To be noted, the top selector is set to -4px because the gradient is too strong initially, pulling it up some makes it less harsh. */
.space{
flex: 1;
position: relative;
padding: 0;
margin: 0;
left: 0;
bottom: 0;
width:100%;
height: 1rem;
background: grey;
background: -webkit-linear-gradient(#333333 -290%, transparent 100%);
background: -o-linear-gradient(#333333 -290%, transparent 100%);
background: -mox-linear-gradient(#333333 -290%, transparent 100%);
background: linear-gradient(#333333 -290%, transparent 100%);
transition: 1s ease;
z-index: -1;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="wrapper">
<div class="paper">
<img src="https://www.jbhifi.com.au/FileLibrary/ProductResources/Images/216422-M-LO.jpg">
<div class="poster">
<h2>Featured</h2>
<h1>Big Baby Swing</h1>
<p>Does he look like hes stupid. Did he drive well? No. Then is he stupid? He's a good kid that's like the devil behind a wheel. That's all you need to know about him..</p>
More
</div>
</div>
<div class="space"></div>
</div>
</body>