Adding 3 different buttons on to a semi-transparent area - html

I need help to
How can I add two more image buttons inside the semi transparent area (<figcaption>) and all 3 buttons to be vertically centered and distributed equally inside the semi transparent area?
The button I've added seems to be semi-transparent (same as the <figcaption> opacity). I need the buttons to be opacity:1;?
This is the code:
<div class="container demo-2">
<ul class="grid cs-style-2">
<li>
<figure>
<gt_descA>Chair</gt_descA>
<gt_descC>$87.34</gt_descC>
<img src="imagez/designs/thumbs/0/01.jpg" alt="img02">
<figcaption>
<span class="hint hint--top hint--rounded" data-hint="Zoom Image"><img src="additional/buttons/bu_zoom.jpg"></img></span>
</figcaption>
</figure>
</li>
</ul>
</div>
CSS
.grid {
padding: 70px 20px 100px 20px;
max-width: 1300px;
margin: 0 auto;
list-style: none;
text-align: center;
}
.grid li {
display: inline-block;
width: 234px;
margin: 0;
padding: 20px;
text-align: left;
position: relative;
}
.grid figure {
margin: 0;
position: relative;
}
.grid figure img {
max-width: 100%;
display: block;
position: relative;
}
.grid figcaption {
position: absolute;
top: 0;
left: 0;
padding: 20px;
background: #000;
color: #ed4e6e;
opacity:0;
}
/*button*/
.grid figcaption a {
display: inline-block;
}
/* Caption Style*/
.cs-style-2 figure figcaption {
z-index: 10;
-webkit-transition: -webkit-transform 0.4s;
-moz-transition: -moz-transform 0.4s;
transition: transform 0.4s;
}
.no-touch .cs-style-2 figure:hover figcaption,
.cs-style-2 figure.cs-hover figcaption {
-webkit-transform: translateY(0px);
-moz-transform: translateY(0px);
-ms-transform: translateY(0px);
transform: translateY(0px);
opacity:0.6;
}
.cs-style-2 figcaption {
height: 24px;
width: 187px;
top: auto;
bottom: 0px;
}
.cs-style-2 figcaption a {
position: absolute;
right: 20px;
top: 30px;
}
#media screen and (max-width: 31.5em) {
.grid {
padding: 10px 10px 100px 10px;
}
.grid li {
width: 100%;
min-width: 234px;
}
}

You can add buttons, and to align them use
container {
text-align: center;
}
Or this:
container {
max-width: someval;
margin: 0 auto; // no vertical, auto horizontal
}
And the alpha filter (opacity) is added to child elements too! Try to setting value for them too; seperately..

Related

Adding a transition to a card

.grid_content {
max-width: 700px;
margin: 0 auto;
position: relative;
overflow: hidden;
}
img {
width: 100%;
height: 100%;
display: block;
}
.caption {
position: absolute;
z-index: 1;
bottom: 0;
padding: 30px;
colour: white;
width: 100%;
height: 100%;
opacity: 0;
transition: 1s;
}
h4 {
font-family: var(--font-style-custom);
letter-spacing: 3px;
}
p {
margin: 5px;
}
h4,
p {
position: relative;
top: 85px;
}
.caption:hover {
transition: 1s;
opacity: 1;
background: linear-gradient(hsl(0, 0%, 100%, 0.1), hsl(0 0% 0% / 0.6));
}
<div class="grid_content">
<img src="https://img.freepik.com/free-psd/box-packaging-mockup-isolated_23-2149208917.jpg?w=740&t=st=1663223199~exp=1663223799~hmac=6f0288bfcdf858b4908269c5406636c1f3c0bfca3e70041f67d9adc5b0be7dea" alt="Brading image">
<div class="caption">
<h4>Laynard</h4>
<p>Brand-identity</p>
</div>
</div>
Whenever I hover on the image, I want the background color to slowly transition in and out, but here it only transitions in and disappears when I don't hover, I've added transition to the caption div element in the card and it still didn't work
As initially the opacity of the element with the class caption's opacity is set to 0, it's recommended to include the background property in .caption {...} rather than in .caption:hover {...}.
Additionally, remove the transition property in .caption:hover as it's useless.
The issue with your implementation is that when the cursor hovers over the element, the background property is set, and when the cursor is not longer hovering over the element, the background property is reset and the transiton property doesn't get applied to it.
.grid_content {
max-width: 700px;
margin: 0 auto;
position: relative;
overflow: hidden;
}
img {
width: 100%;
height: 100%;
display: block;
}
.caption {
position: absolute;
z-index: 1;
bottom: 0;
padding: 30px;
colour: white;
width: 100%;
height: 100%;
opacity: 0;
transition: 1s;
background: linear-gradient(hsl(0, 0%, 100%, 0.1), hsl(0 0% 0% / 0.6));
}
h4 {
font-family: var(--font-style-custom);
letter-spacing: 3px;
}
p {
margin: 5px;
}
h4,
p {
position: relative;
top: 85px;
}
.caption:hover {
opacity: 1;
}
<div class="grid_content">
<img src="https://img.freepik.com/free-psd/box-packaging-mockup-isolated_23-2149208917.jpg?w=740&t=st=1663223199~exp=1663223799~hmac=6f0288bfcdf858b4908269c5406636c1f3c0bfca3e70041f67d9adc5b0be7dea" alt="Brading image">
<div class="caption">
<h4>Laynard</h4>
<p>Brand-identity</p>
</div>
</div>
Move your background style from .caption:hover to .caption
You already made the transition of opacity
.grid_content {
max-width: 700px;
margin: 0 auto;
position: relative;
overflow: hidden;
}
img {
width: 100%;
height: 100%;
display: block;
}
.caption {
position: absolute;
z-index: 1;
bottom: 0;
padding: 30px;
colour: white;
width: 100%;
height: 100%;
opacity: 0;
transition: 1s;
background: linear-gradient(hsl(0, 0%, 100%, 0.1), hsl(0 0% 0% / 0.6));
}
h4 {
font-family: var(--font-style-custom);
letter-spacing: 3px;
}
p {
margin: 5px;
}
h4,
p {
position: relative;
top: 85px;
}
.caption:hover {
transition: 1s;
opacity: 1;
}
<div class="grid_content">
<img src="https://img.freepik.com/free-psd/box-packaging-mockup-isolated_23-2149208917.jpg?w=740&t=st=1663223199~exp=1663223799~hmac=6f0288bfcdf858b4908269c5406636c1f3c0bfca3e70041f67d9adc5b0be7dea" alt="Brading image">
<div class="caption">
<h4>Laynard</h4>
<p>Brand-identity</p>
</div>
</div>

CSS Slide effect into container

I'd like to get this effect:
But I cant move only the content, leaving fixed the container. If you see my fiddle, I'm moving all together, the content and the container.
And even I'd like to put the hover on the circle div, not in the content like it is right now, because now when the animation ends it losing the hover.
A little detail to keep in mind:
I need to update at runtime the text to display due it should be
translated depending on the language selected by the user.
Here is my fiddle
.frame {
display: flex;
background-color: green;
height: 200px;
width: 200px;
flex-direction: center;
justify-content: center;
align-items: center;
}
.oval {
display: flex;
background-color: white;
border-radius: 50px;
width: 100px;
height: 100px;
}
.box {
display: flex;
flex-direction: column;
background-color: gray;
height: 100px;
width: 100px;
position: relative;
top: 25px;
transition: top 200ms ease-in;
border-radius: 50px;
}
.box:hover {
top: -50px;
transition: top 200ms ease-in;
animation: ticker 25s cubic-bezier(1, 0, .5, 0);
}
#keyframes ticker {
0% {
margin-top: 0
}
25% {
margin-top: -30px
}
50% {
margin-top: -60px
}
75% {
margin-top: -90px
}
100% {
margin-top: 0
}
}
.box-inn {
flex: 1;
margin: 5%;
color: white;
text-align: center;
align-items: center;
}
.first {
background-color: blue;
}
.second {
background-color: red;
}
<div class="frame">
<div class="oval">
<div class="box">
<div class="box-inn first">
Text 1
</div>
<div class="box-inn second">
Text 2
</div>
</div>
</div>
</div>
You can use pseudo-elements. First hide :after with transform: translateY(100%) and overflow: hidden on parent, and on hover you translate :before for 100% and move :after to 0.
.elem {
position: relative;
width: 100px;
height: 100px;
border: 1px solid white;
color: white;
border-radius: 50%;
background: #4CA5D0;
overflow: hidden;
}
.elem:after,
.elem:before {
content: 'Top';
position: absolute;
transition: all 0.3s ease-in;
top: 0;
left: 0;
height: 100%;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.elem:after {
content: 'Bottom';
transform: translateY(100%);
}
.elem:hover:before {
transform: translateY(-100%);
}
.elem:hover:after {
transform: translateY(0);
}
<div class="elem"></div>
If you don't want to use pseudo-elements Fiddle
If your icons are images you may want a non-pseudo element method. Here's an example using a font awesome icon to illustrate an image (fa icons can be used with pseudo elements, however)
.link {
position: relative; /* for absolute positioned children to work */
display: inline-flex;
flex-direction: column;
height: 100px; /* this method uses absolutely position chldren so..*/
width: 100px; /* ..a fixed width and height was needed */
color: white;
border-radius: 100%;
border-color: white;
border-style: solid;
border-width: 2px;
overflow: hidden; /* hides the overflowing elements */
}
.icon {
position: absolute;
top: 50%; /* vertically position icon in center in combination with transform -50% */
left: 50%; /* same deal with horizontal centering */
transform: translate(-50%, -50%); /* horizontal, vertical */
transition: all 0.2s ease;
}
.text {
position: absolute;
top: 150%; /* positions text under the .link container element */
left: 50%;
transform: translate(-50%, -50%);
transition: all 0.2s ease;
}
.link:hover .icon {
top: -50%; /* positions icon above the .link container element */
}
.link:hover .text {
top: 50%; /* moves text into center of .link container element */
}
/* styling - ignore */
body {display: flex;justify-content: center;align-items: center; height: 100vh;margin: 0;font-size: 24px;background-color: hsl(189, 72%, 45%);font-variant: small-caps;font-family: verdana;}.icon i {font-size: 40px;}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet"/>
<a class="link" href="https://jsfiddle.net/Hastig/4akmbgc1/">
<div class="icon"><i class="fa fa-home"></i></div>
<div class="text">fiddle</div>
</a>
fiddle
https://jsfiddle.net/Hastig/4akmbgc1/
Following #Nenad Vracar answer:
On:
I need to update at runtime the text to display due it should be
translated depending on the language selected by the user.
You can use data-attributes along with the attr() CSS function in the pseudo-elements' content property.
Note: Change these data-attributes with JS in your language handling logic.
.elem {
position: relative;
width: 100px;
height: 100px;
border: 1px solid white;
color: white;
border-radius: 50%;
background: #4CA5D0;
overflow: hidden;
}
.elem:after,
.elem:before {
content: attr(data-top-text);
position: absolute;
transition: all 0.3s ease-in;
top: 0;
left: 0;
height: 100%;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.elem:after {
content: attr(data-bottom-text);
transform: translateY(100%);
}
.elem:hover:before {
transform: translateY(-100%);
}
.elem:hover:after {
transform: translateY(0);
}
<div class="elem" data-top-text="top_text" data-bottom-text="bottom_text"></div>
Another alternative is to use the :lang pseudo-class.
Using lang attribute in the element.
.elem {
position: relative;
width: 100px;
height: 100px;
border: 1px solid white;
color: white;
border-radius: 50%;
background: #4CA5D0;
overflow: hidden;
}
.elem:after,
.elem:before {
content: "top_text";
position: absolute;
transition: all 0.3s ease-in;
top: 0;
left: 0;
height: 100%;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.elem:after {
content: "bottom_text";
transform: translateY(100%);
}
.elem:hover:before {
transform: translateY(-100%);
}
.elem:hover:after {
transform: translateY(0);
}
.elem:lang(es):before {
content: "texto_superior";
}
.elem:lang(es):after {
content: "texto_inferior";
}
<div class="elem"></div>
<div class="elem" lang="es"></div>
Changing the html lang attribute:
document.getElementById('change-lang').addEventListener('click', function() {
document.documentElement.setAttribute('lang', 'es');
});
.elem {
position: relative;
width: 100px;
height: 100px;
border: 1px solid white;
color: white;
border-radius: 50%;
background: #4CA5D0;
overflow: hidden;
}
.elem:after,
.elem:before {
content: "top_text";
position: absolute;
transition: all 0.3s ease-in;
top: 0;
left: 0;
height: 100%;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}
.elem:after {
content: "bottom_text";
transform: translateY(100%);
}
.elem:hover:before {
transform: translateY(-100%);
}
.elem:hover:after {
transform: translateY(0);
}
:lang(es) .elem:before {
content: "texto_superior";
}
:lang(es) .elem:after {
content: "texto_inferior";
}
<div class="elem"></div>
<button id="change-lang">Cambiar a EspaƱol</button>

How to vertically center on hover element text?

I have a text element that appears over the image on mouseover. The text bit is horizontally centered but I'm still having troubles centering it vertically despite trying several techniques. Trying to achieve this without Javascript.
HTML:
<figure class="wp-caption-my">
<img class="demo-my" src="image.png" alt="Image" />
<figcaption class="wp-caption-text-my">This is a caption text</figcaption>
</figure>
CSS:
.wp-caption-my {
position: relative;
padding: 0;
margin: 0;
}
.wp-caption-my img {
display: block;
max-width: 100%;
height: auto;
}
.wp-caption-text-my {
opacity: 0;
position: absolute;
width: 100%;
height: 100%;
color: #fff;
left: 0;
bottom: 0;
padding: 0.75em 1em;
font-weight: 700;
z-index: 2;
-webkit-box-sizing: border-box;
box-sizing: border-box;
background-color: rgba(0,191,255,0.9);
text-align: center;
-webkit-transition: opacity .3s ease-in-out !important;
transition: opacity .3s ease-in-out !important;
}
.wp-caption-my:hover .wp-caption-text-my {
opacity: 1;
}
img.demo-my {
width: 100% !important;
height: 100% !important;
}
I think you can use CSS pseudo elements this way:
.wp-caption-my {
position: relative;
padding: 0;
margin: 0;
}
.wp-caption-my img {
display: block;
max-width: 100%;
height: auto;
}
.wp-caption-text-my {
opacity: 0;
position: absolute;
width: 100%;
height: 100%;
color: #fff;
left: 0;
bottom: 0;
padding: 0.75em 1em;
font-weight: 700;
z-index: 2;
-webkit-box-sizing: border-box;
box-sizing: border-box;
background-color: rgba(0,191,255,0.9);
text-align: center;
-webkit-transition: opacity .3s ease-in-out !important;
transition: opacity .3s ease-in-out !important;
}
.wp-caption-my:hover .wp-caption-text-my {
opacity: 1;
}
.wp-caption-text-my::before {
content: "";
display: inline-block;
width: 0px;
height: 100%;
vertical-align: middle;
}
.wp-caption-text-my span {
display: inline-block;
vertical-align: middle;
}
img.demo-my {
width: 100% !important;
height: 100% !important;
}
<figure class="wp-caption-my">
<img class="demo-my" src="http://janisweb.tk/grahams/wp-content/uploads/2016/07/officewaste.png" alt="Image" />
<figcaption class="wp-caption-text-my"><span>This is a caption text</span></figcaption>
</figure>
This is done by wrapping your text in a span and adding this CSS to your styles:
.wp-caption-text-my::before {
content: "";
display: inline-block;
width: 0px;
height: 100%;
vertical-align: middle;
}
.wp-caption-text-my span {
display: inline-block;
vertical-align: middle;
}
Wrap the text inside another element, and set top:
HTML
<figcaption class="wp-caption-text-my"><h3>This is a caption text</h3></figcaption>
CSS
.wp-caption-text-my h3 {
position: relative;
top: 50%;
line-height: 18px;
margin-top: -18px;
}
Check it with more text:
Codepen: https://codepen.io/anon/pen/LkAyEd
Aligning your text to the center of your image, using pseudo element :before on-hover.
.wp-caption-text-my:before{
content:'';
display:block;
width:100%;
height:50%;
background:#f22;
}
I have added background color to pseudo element, so you could understand what it does and then you can align it accordingly to your needs.
.wp-caption-my {
position: relative;
padding: 0;
margin: 0;
}
.wp-caption-my img {
display: block;
max-width: 100%;
height: auto;
}
.wp-caption-text-my {
opacity: 0;
position: absolute;
width: 100%;
height: 100%;
color: #fff;
left: 0;
bottom: 0;
padding: 0.75em 1em;
font-weight: 700;
z-index: 2;
-webkit-box-sizing: border-box;
box-sizing: border-box;
background-color: rgba(0,191,255,0.9);
text-align: center;
-webkit-transition: opacity .3s ease-in-out !important;
transition: opacity .3s ease-in-out !important;
}
.wp-caption-text-my:before{
content:'';
display:block;
width:100%;
height:50%;
background:#f22;
}
.wp-caption-my:hover .wp-caption-text-my {
opacity: 1;
}
img.demo-my {
width: 100% !important;
height: 100% !important;
}
<figure class="wp-caption-my">
<img class="demo-my" src="https://source.unsplash.com/random" alt="Image" />
<figcaption class="wp-caption-text-my">This is a caption text
<figcaption style="padding-top:5px;">Add such more captions</figcaption>
<figcaption style="padding-top:5px;">And style them as you want.</figcaption>
</figcaption>
</figure>
To center horizontally and vertically an absolute element you can easily do
position: absolute
margin: auto;
top: 0; left: 0; bottom: 0; right: 0;
fiddle here: http://jsfiddle.net/mBBJM/1/
from https://codemyviews.com/blog/how-to-center-anything-with-css#comment-684580538

How to center horizontally a position: absolute elment on a position: fixed container

I need to center horizontally a button with aboslute position (because it must keep on top when to click and launch overlay and click to close overlay) on a position fixed topbar, here is the code:
.topbar {
text-align: center;
min-width: 100%;
height: 50px;
background-color: #29343a;
position: fixed;
top: 0;
}
.button {
display: inline-block;
margin-right: auto;
margin-left: auto;
width: 60px;
height: 50px;
cursor: pointer;
background-color: #00c1e2;
border-bottom: 2px solid #00a8c6;
z-index: 100;
position: absolute;
}
.overlay {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
background: rgba(153,204,51,0.9);
}
Thats is just the css of the three parts, the website is more complex but i think that 3 parts are the key. the topbar must be fixed on top, the buton have to be centered into the topbar div, and the overlay launch and the buttop keeps on top of the overlay.
What is working: the overlay works fine and the button keeps on top but its not horizontally centered on the topbar.
How i can hack this?
You could to the left:0 and right:0 trick.
.button {
display: inline-block;
margin-right: auto;
margin-left: auto;
width: 60px;
height: 50px;
cursor: pointer;
background-color: #00c1e2;
border-bottom: 2px solid #00a8c6;
z-index: 100;
position: absolute;
left: 0; /*added*/
right: 0; /*added*/
}
Or do the left:50% with negative left margin (half width).
.button {
display: inline-block;
width: 60px;
height: 50px;
cursor: pointer;
background-color: #00c1e2;
border-bottom: 2px solid #00a8c6;
z-index: 100;
position: absolute;
left: 50%; /*added*/
margin-left: -30px; /*added*/
}
Or use CSS3 transform.
.button {
display: inline-block;
width: 60px;
height: 50px;
cursor: pointer;
background-color: #00c1e2;
border-bottom: 2px solid #00a8c6;
z-index: 100;
position: absolute;
left: 50%; /*added*/
transform: translateX(-50%); /*added*/
}
Based on the information you provided this is what I could come up with:
/* CSS */
.topBar {
position:fixed;
top:0;
left:0;
width:100%;
height:auto;
background-color:#29343a;
}
.overlay {
display:none;
width: 100%;
background: rgba(153,204,51,0.9);
margin:0;
}
.button, .button:active, .button:visited, .button:hover {
display: block;
position:relative;
text-align:center;
cursor: pointer;
background-color: #00c1e2;
border-bottom: 2px solid #00a8c6;
margin:0 auto;
padding:10px;
}
.topBar:hover > .overlay {
display:block;
}
And I added some html because you didn't provide any:
<!-- HTML -->
<div class="topBar">
Button
<div class="overlay">
<p>Some text shows when button hover</p>
</div>
</div>
JSFIDDLE: https://jsfiddle.net/0napm6y3/
Here is the complete code of this component made on react:
This is the react component, the overlay launch is the overlay var, the other one is for one animation on the button:
var React = require('react');
var StatusBarButtonView = React.createClass({
getInitialState: function() {
return {cliked: false};
},
handleClick: function(event) {
this.setState({cliked: !this.state.cliked});
},
render: function() {
var fondo = this.state.cliked ? 'active' : '';
var overlay = this.state.cliked ? 'open' : '';
return (
<div>
<div className={"aui-profit-statusbar-button-container " + (fondo)} onClick={this.handleClick}>
<img src="images/aui-navbar-element-icon-cross.png" className={"rotate " + (fondo)}/>
</div>
<div className={"overlay overlay-slidedown " + (overlay)}>
<nav>
<ul>
<li>Home</li>
<li>About</li>
<li>Work</li>
<li>Clients</li>
<li>Contact</li>
</ul>
</nav>
</div>
</div>
);
}
});
module.exports = StatusBarButtonView;
Here is the topbar scss:
.aui-profit-statusbar-container {
text-align: center;
min-width: 100%;
height: 50px;
background-color: #29343a;
position: fixed;
top: 0;
}
Here is the button scss:
.aui-profit-statusbar-button-container {
display: inline-block;
margin-right: auto;
margin-left: auto;
width: 60px;
height: 50px;
cursor: pointer;
background-color: #00c1e2;
border-bottom: 2px solid #00a8c6;
z-index: 100;
position: absolute;
left: 0;
right: 0;
&:hover {
background-color: #56d9f6;
}
&.active {
background-color: #ff4b39;
border-bottom: 2px solid #e43f30;
}
.rotate {
margin-top: 13px;
width: 23px;
height: 23px;
-webkit-transition-duration: 0.2s;
-moz-transition-duration: 0.2s;
-ms-transition-duration: 0,2s;
-o-transition-duration: 0.2s;
transition-duration: 0.2s;
-webkit-transition-property: -webkit-transform;
-moz-transition-property: -moz-transform;
-ms-transition-property: -ms-transform;
-o-transition-property: -o-transform;
transition-property: transform;
}
.active {
-webkit-transform: rotate(135deg);
-moz-transform: rotate(135deg);
-ms-transform: rotate(135deg);
-o-transform: rotate(135deg);
transform: rotate(135deg);
}
}
Here is the overlay css:
/* Overlay style */
.overlay {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
background: rgba(153,204,51,0.9);
}
/* Overlay closing cross */
.overlay .overlay-close {
width: 80px;
height: 80px;
position: absolute;
right: 20px;
top: 20px;
overflow: hidden;
border: none;
background: url(../img/cross.png) no-repeat center center;
text-indent: 200%;
color: transparent;
outline: none;
z-index: 100;
}
/* Menu style */
.overlay nav {
text-align: center;
position: relative;
top: 50%;
height: 60%;
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
}
.overlay ul {
list-style: none;
padding: 0;
margin: 0 auto;
display: inline-block;
height: 100%;
position: relative;
}
.overlay ul li {
display: block;
height: 20%;
height: calc(100% / 5);
min-height: 54px;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
.overlay ul li a {
font-size: 54px;
font-weight: 300;
display: block;
color: #fff;
-webkit-transition: color 0.2s;
transition: color 0.2s;
}
.overlay ul li a:hover,
.overlay ul li a:focus {
color: #e3fcb1;
}
/* Effects */
.overlay-slidedown {
visibility: hidden;
-webkit-transform: translateY(-100%);
transform: translateY(-100%);
-webkit-transition: -webkit-transform 0.4s ease-in-out, visibility 0s 0.4s;
transition: transform 0.4s ease-in-out, visibility 0s 0.4s;
}
.overlay-slidedown.open {
visibility: visible;
-webkit-transform: translateY(0%);
transform: translateY(0%);
-webkit-transition: -webkit-transform 0.4s ease-in-out;
transition: transform 0.4s ease-in-out;
}
#media screen and (max-height: 30.5em) {
.overlay nav {
height: 70%;
font-size: 34px;
}
.overlay ul li {
min-height: 34px;
}
}
Now it works perfectly, thanks to all.
Next thing i have to do is separate overlay of buttom component. and keep it running, but im wondering to to pass the action to one component to another.... i have to learn more about react.js

:after element with rotate moving on resize

I have a :before and an :after element (for shadow purposes) with a transform: rotate applied to it. The :before stays in place when the viewport is resized, however the :after moves slightly up and down. If the rotate is removed, it stays in place on resize. How can I make it stay in place on resize with the roate?
I have put a z-index: 1 on the :before and :after for visibility of the issue
It's the shadow #3
http://codepen.io/mildrenben/details/jEYpyP/
HTML:
<h2>Shadow #3</h2>
<div class="row shadow-3">
<div class="shadow-box">
<img>
</div>
<div class="shadow-box">
<img>
</div>
<div class="shadow-box">
<img>
</div>
<div class="shadow-box">
<img>
</div>
</div>
CSS:
html, body {
width: 100%;
height: 100%;
}
.row {
height: 160px;
width: 80%;
margin: 0 auto 60px;
display: block;
img:nth-of-type(1) {
content: url(http://marshall.org/wp-content/themes/marshall/img/featured-space-policy.jpg);
}
img:nth-of-type(2) {
content: url(http://i.dailymail.co.uk/i/pix/2014/09/04/1409790551890_wps_28_Astronaut_Reid_Wiseman_po.jpg);
}
img:nth-of-type(3) {
content: url(http://cdn2.collective-evolution.com/assets/uploads/2014/08/life_in_space-728x400.jpg);
}
img:nth-of-type(4) {
content: url(http://s.ngm.com/2007/10/space-travel/img/space_feature.jpg);
}
}
img {
width: 23%;
margin: 0 1% 0 0;
height: 100%;
transition: all 0.2s ease-in-out;
cursor: pointer;
}
.shadow-box {
width: 23%;
margin: 0 1% 0 0;
height: 100%;
transition: all 0.2s ease-in-out;
cursor: pointer;
display: inline-block;
img {
width: 100%;
height: 100%;
&:hover {
transform: translateY(-4px);
}
}
}
.shadow-box:before, .shadow-box:after {
content: '';
z-index: 1;
position: absolute;
width: 8%;
height: 110px;
background: red;
transform: skew(-10deg) rotate(-6deg) translate(calc(3% + 10px), 31px);
transition: all 0.2s ease-in-out;
}
.shadow-box:after {
transform: skew(10deg) rotate(6deg) translate(126%, -146px);
}
.shadow-box:hover:before, .shadow-box:hover:after {
box-shadow: 0 20px 20px lighten($black, 40%);
}
I don't think using translates is the way to go here, I'd set the container to position: relative; and then use absolute positioning to position the shadow things: http://jsfiddle.net/bpma9ko4/
Here the relevant parts:
.shadow-box {
width: 45%;
margin: 0 1% 0 0;
height: 100%;
transition: all 0.2s ease-in-out;
cursor: pointer;
display: inline-block;
position: relative;
}
.shadow-box:before, .shadow-box:after {
content: '';
z-index: 1;
position: absolute;
width: 40%;
height: 110px;
background: red;
transform: skew(-10deg) rotate(-6deg);
transition: all 0.2s ease-in-out;
top: 20px;
left: 20px;
}
.shadow-box:after {
transform: skew(10deg) rotate(6deg);
right: 20px;
left: auto;
}
In your example, when I removed the translates, the red box on the right went underneath the image (on a new line) and then you tried dragging it up with translates, but to me it is a much more direct way if you just place it over the image to begin with, using the top/left/right attributes.
Note: My example is simplified, it doesn't have shadows and other things, it's cut down to the parts relevant to the question.
The whole code:
html, body {
width: 100%;
height: 100%;
}
.row {
height: 160px;
width: 80%;
margin: 0 auto 60px;
display: block;
img:nth-of-type(1) {
content: url(http://marshall.org/wp-content/themes/marshall/img/featured-space-policy.jpg);
}
img:nth-of-type(2) {
content: url(http://i.dailymail.co.uk/i/pix/2014/09/04/1409790551890_wps_28_Astronaut_Reid_Wiseman_po.jpg);
}
img:nth-of-type(3) {
content: url(http://cdn2.collective-evolution.com/assets/uploads/2014/08/life_in_space-728x400.jpg);
}
img:nth-of-type(4) {
content: url(http://s.ngm.com/2007/10/space-travel/img/space_feature.jpg);
}
}
img {
width: 100%;
margin: 0 1% 0 0;
height: 100%;
transition: all 0.2s ease-in-out;
cursor: pointer;
}
.shadow-box {
width: 45%;
margin: 0 1% 0 0;
height: 100%;
transition: all 0.2s ease-in-out;
cursor: pointer;
display: inline-block;
position: relative;
}
.shadow-box:before, .shadow-box:after {
content: '';
z-index: 1;
position: absolute;
width: 40%;
height: 110px;
background: red;
transform: skew(-10deg) rotate(-6deg);
transition: all 0.2s ease-in-out;
top: 20px;
left: 20px;
}
.shadow-box:after {
transform: skew(10deg) rotate(6deg);
right: 20px;
left: auto;
}
.shadow-box:hover:before, .shadow-box:hover:after {
box-shadow: 0 20px 20px lighten($black, 40%);
}
<h2>Shadow #3</h2>
<div class="row shadow-3">
<div class="shadow-box">
<img src="http://placehold.it/466x180">
</div>
<div class="shadow-box">
<img src="http://placehold.it/466x180">
</div>
<div class="shadow-box">
<img src="http://placehold.it/466x180">
</div>
<div class="shadow-box">
<img src="http://placehold.it/466x180">
</div>
</div>