I'm trying to make the image on the left of the following page resize like the images on the right when the browser window is made smaller/bigger:
http://www.hugoproject.com/test.html
I am using a sprite for the image on the left. My code is as follows:
HTML
<div id="home-projects">
<div id="projects">
<div class="project-group">
<div class="project">
Arrow<span></span>
</div>
</div>
</div>
CSS
#home-projects {
text-align: center;
overflow: hidden;
position: relative;
}
#projects {
width: 100%;
}
.project-group {
width: 100%;
height: 100%;
position: absolute;
}
.project {
float: left;
text-align: center;
width: 33.3%;
}
.project-link {
background-size: cover;
background-repeat: no-repeat;
background-position: center;
background-color: #adadad;
position: relative;
overflow: hidden;
display: inline-block;
width: 80%;
}
.circle .project-link, .circle .project-link .hover {
border-radius: 100%;
-moz-border-radius: 100%;
-webkit-border-radius: 100%;
}
.project-link .hexagon-top {
content: '';
display: block;
position: absolute;
left: 0;
border-style: solid;
border-bottom-color: transparent;
border-left-color: #dfdfdf;
border-right-color: #dfdfdf;
width: 0;
height: 0;
z-index: 2;
}
.project-link .hexagon-bottom {
content: '';
display: block;
position: absolute;
left: 0;
bottom: 0;
border-style: solid;
border-top-color: transparent;
border-left-color: #dfdfdf;
border-right-color: #dfdfdf;
width: 0;
height: 0;
z-index: 2;
}
.project-link .hover {
position: absolute;
width: 100%;
height: 100%;
font-size: 14px;
text-align: center;
color: #fff;
background: #ec6136;
text-decoration: none;
text-transform: uppercase;
display: block;
opacity: 0;
transition: all .3s;
-moz-transition: all .3s;
-webkit-transitin: all .3s;
}
.project-link .hover-text {
display: block;
margin-top: 45%;
}
.project-link .hover-text:after {
content: '>';
font-family: 'icon';
font-size: 12px;
margin-left: 15px;
}
.project-link:hover > .hover {
opacity: .9;
}
.HS {
display: inline-block;
position: relative;
text-indent: -9999px;
width: 283px;
height: 213px;
background: url(http://www.hugoproject.com/ftp1/images/icons.png) no-repeat;
}
.HS span {
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
background: url(http://www.hugoproject.com/ftp1/images/icons.png) no-repeat;
background-position: 0 -214px;
opacity: 0;
-webkit-transition: opacity 0.5s;
-moz-transition: opacity 0.5s;
-o-transition: opacity 0.5s;
}
.HS:hover span {
opacity: 1;
}
What am I doing wrong?
This resizes it like you want (in Firefox at least, haven't tested elsewhere). Mainly have to use %'s, not fixed size in order to scale.
.HS {
display: inline-block;
position: relative;
text-indent: -9999px;
width: 100%;
height: 75%;
background-image: url("http://www.hugoproject.com/ftp1/images/icons.png");
background-position: 0px 0px;
background-size: 800%;
}
.HS span {
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
background-image: url("http://www.hugoproject.com/ftp1/images/icons.png");
background-position: 0px -100%;
opacity: 0;
width: 100%;
height: 100%;
background-size: 800%;
-webkit-transition: opacity 0.5s;
-moz-transition: opacity 0.5s;
-o-transition: opacity 0.5s;
}
.project {
float: left;
text-align: center;
width: 33.3%;
height:100%;
}
Another, possibly better, option would be to actually crop your PNG into separate images rather than selecting the position so that you can use the same CSS as with your other images.
Related
I'm trying to achieve div border in the convex shape and on hover it should be in normal square shape. I have added in the bottom as same I want to add on the top I tried using before but unable to achieve the result. Can anyone help me Below is my code so far I have done.
Any help will be appreciated
* {
box-sizing: border-box;
}
.services {
position: relative;
width: 500px;
height: 420px;
margin: 100px;
background-color: #cccccc;
transition: all 0.2s ease;
animation: down-bump 0.4s ease;
}
.services:before {
}
.serv_section {
top: 83%;
position: relative;
overflow: hidden;
padding: 50px 0 0;
}
.serv_inner {
position: relative;
background: #fff;
height: 25px;
}
.serv_inner:after {
box-shadow: 0 0 0 80px #fff;
border-radius: 100%;
position: absolute;
height: 150px;
content: '';
right: -20%;
left: -20%;
top: -150px;
transition: all 0.4s ease-in-out;
}
.services:hover .serv_inner:after {
top: -120px;
}
.serv_inner:before {
/* box-shadow: 0 0 0 80px #fff;
border-radius: 100%;
position: absolute;
height: 150px;
content: '';
right: -20%;
left: -20%;
top: 130px;
transition: all 0.4s ease-in-out; */
}
span.image_caption {
position: absolute;
color: red;
padding: 10px 20px;
font-size: 30px;
z-index: 10;
animation-duration: 2.5s;
animation-fill-mode: both;
}
span.image_caption p {
font-size: 32px;
font-weight: 900;
font-family: 'Dancing Script', cursive;
color: cadetblue;
}
<div class='services'>
<div class="serv_section">
<div class="serv_inner">
</div>
</div>
</div>
You can use the before and after elements to make the curve, on hover hide the psuedo elements behind the element and remove the curve like this:
.services {
position: relative;
width: 100px;
height: 60px;
margin: 100px;
background-color: #cccccc;
z-index: 0;
}
.services:hover:before{
top: 0px;
border-radius: 0;
}
.services:hover:after{
bottom: 0px;
border-radius: 0;
}
.services:before, .services:after{
content: ' ';
position: absolute;
width: 100%;
height: 40px;
background-color: #cccccc;
border-radius: 50%;
z-index: -1;
transition: all .4s;
}
.services:before {
top: -20px;
}
.services:after {
bottom: -20px;
}
<div class='services'>
</div>
If I understand it right you can achieve this by simple using of different values for horizontal and vertical dimensions of the border-radius property (more info at https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius):
div {
background: grey;
height: 100px;
width: 200px;
transition: border-radius .15s ease-out;
}
/* border-radius on default state */
div {
border: 4px solid black;
border-radius: 50%/20px;
}
div:hover {
border-radius: 0;
}
<div></div>
I've made a simple css key frame animation that occurs when the page is loaded. However, the page background-image sticks to the text. You can see my problem here
https://codepen.io/gavdraws/pen/OmpEjK
Any ideas what I'm doing wrong?
Cheers
You have applied a background-image to .home and the text elements have class .home, so each of them has a background-image.
I think you want that background on the element that wraps the text elements (.pageCont) - not every .home element.
/* - - - - - Nav Icons - - - - - */
/* Profile */
$(document).ready(function(){
$("#top").hover(function() {
$("#profile").css("background-image", "url(img/nav-icons/Profile-light.png)");
}, function() {
$("#profile").css("background-image", "url(img/nav-icons/Profile-dark.png)");
});
});
/* CV */
$(document).ready(function(){
$("#left").hover(function() {
$("#cv").css("background-image", "url(img/nav-icons/CV-light.png)");
}, function() {
$("#cv").css("background-image", "url(img/nav-icons/CV-dark.png)");
});
});
/* Contact */
$(document).ready(function(){
$("#bottom").hover(function() {
$("#contact").css("background-image", "url(img/nav-icons/Contact-light.png)");
}, function() {
$("#contact").css("background-image", "url(img/nav-icons/Contact-dark.png)");
});
});
/* Work */
$(document).ready(function(){
$("#right").hover(function() {
$("#work").css("background-image", "url(img/nav-icons/Work-light.png)");
}, function() {
$("#work").css("background-image", "url(img/nav-icons/Work-dark.png)");
});
});
html, body {
height:100%;
width: 100%;
margin:0;
padding:0;
}
h2{
font-family: 'Lato', sans-serif;
font-size: 33pt;
font-style: bold;
text-transform: uppercase;
}
h2.home{
color: #EDEDED;
}
p{
font-family: 'Lato', sans-serif;
font-size: 12pt;
}
p.home{
color: #EDEDED;
}
/*.preloader {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: black;
z-index: 2000;
background-image: url(../gfx/logo/logo.gif) !important;
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
}*/
/*#line{
position: relative;
top: 50%;
bottom: 50%;
}*/
.frame {
position: absolute;
z-index: 1000;
}
.frame.rightFrame {
top: 0px;
right: 0px;
border-right: 45px solid #EDEDED;
border-top: 45px solid transparent;
border-bottom: 45px solid transparent;
height: 100%;
box-sizing: border-box;
}
.frame.rightFrame:hover{
border-right: 45px solid #F1612F;
cursor: pointer;
}
.frame.leftFrame {
top: 0px;
left: 0px;
border-left: 45px solid #EDEDED;
border-top: 45px solid transparent;
border-bottom: 45px solid transparent;
height: 100%;
box-sizing: border-box;
}
.frame.leftFrame:hover{
border-left: 45px solid #F1612F;
cursor: pointer;
}
.frame.topFrame {
top: 0px;
left: 0px;
border-top: 45px solid #EDEDED;
border-left: 45px solid transparent;
border-right: 45px solid transparent;
height: 0px;
width: 100%;
box-sizing: border-box;
}
.frame.topFrame:hover{
border-top: 45px solid #F1612F;
cursor: pointer;
}
.frame.bottomFrame {
bottom: 0px;
left: 0px;
border-bottom: 45px solid #EDEDED;
border-left: 45px solid transparent;
border-right: 45px solid transparent;
height: 0px;
width: 100%;
box-sizing: border-box;
}
.frame.bottomFrame:hover{
border-bottom: 45px solid #F1612F;
cursor: pointer;
}
.pageCont{
position: absolute;
top: 45px;
left: 45px;
right: 45px;
bottom: 45px;
z-index: 950;
overflow: hidden;
}
/* - - - - - Icons formatting - - - - - */
.menuIcon {
z-index: 1001;
cursor: pointer;
}
/* Profile */
.menuIcon#profile {
position: relative;
margin: 0 auto;
width: 45px;
height: 45px;
background-image: url(../img/nav-icons/Profile-dark.png);
background-repeat: no-repeat;
}
#profile:hover ~ .topFrame {
border-top: 45px solid #F1612F !important;
}
#profile:hover {
background-image: url(../img/nav-icons/Profile-light.png) !important;
}
/* CV */
.menuIcon#cv {
top: 50%;
margin-top: -15px;
position: absolute;
width: 45px;
height: 45px;
background-image: url(../img/nav-icons/CV-dark.png);
background-repeat: no-repeat;
}
#cv:hover ~ .leftFrame {
border-left: 45px solid #F1612F !important;
}
#cv:hover {
background-image: url(../img/nav-icons/CV-light.png) !important;
}
/* Contact */
.menuIcon#contact {
position: absolute;
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
bottom: 0 !important;
width: 45px;
height: 45px;
background-image: url(../img/nav-icons/Contact-dark.png);
background-repeat: no-repeat;
}
#contact:hover ~ .bottomFrame {
border-bottom: 45px solid #F1612F !important;
}
#contact:hover {
background-image: url(../img/nav-icons/Contact-light.png) !important;
}
/* Work */
.menuIcon#work {
top: 50%;
right: 0;
margin-top: -15px;
position: absolute;
width: 45px;
height: 45px;
background-image: url(../img/nav-icons/Work-dark.png);
background-repeat: no-repeat;
}
#work:hover ~ .rightFrame {
border-right: 45px solid #F1612F !important;
}
#work:hover{
background-image: url(../img/nav-icons/Work-light.png) !important;
}
.pageCont{
background-image: url("http://www.codeandpepper.com/assets/gfx/start/slide_3.jpg") !important;
background-repeat: no-repeat;
background-attachment: fixed;
background-position: top left;
}
.profile-pic{
position: relative;
margin-top: 30px !important;
width: 150px;
height: auto;
text-align: center;
animation: fadeuptwo 0.8s ease-out forwards;
/* Safari and Chrome */
-webkit-animation: fadeuptwo 0.8s;
}
.centre-div{
text-align: center;
position: relative;
margin: 0 auto !important;
margin-top: 50px !important;
width: 420px;
height: 80%;
animation: fadeup 0.9s ease-out forwards;
/* Safari and Chrome */
-webkit-animation: fadeup 0.9s;
}
#keyframes fadeup {
from {
top: 200px;
opacity: 0;
}
to {
top: 0px;
opacity: 1
}
}
#-webkit-keyframes fadeup {
/* Safari and Chrome */
from {
top: 200px;
opacity: 0;
}
to {
top: 0px;
opacity: 1;
}
}
#keyframes fadeuptwo {
from {
top: 200px;
opacity: 0;
}
to {
top: 0px;
opacity: 1
}
}
#-webkit-keyframes fadeuptwo {
/* Safari and Chrome */
from {
top: 200px;
opacity: 0;
}
to {
top: 0px;
opacity: 1;
}
}
a {
color: #F1612F;
display: inline-block;
position: relative;
text-decoration: none;
cursor: pointer;
}
a:after {
background-color: currentColor;
bottom: 0;
content: '';
display: inline-block;
height: 2.5px;
left: 0;
position: absolute;
right: 0;
-moz-transition: left 0.15s ease-out,right 0.15s ease-out;
-o-transition: left 0.15s ease-out,right 0.15s ease-out;
-webkit-transition: left 0.15s ease-out,right 0.15s ease-out;
transition: left 0.15s ease-out,right 0.15s ease-out;
}
a:hover:after {
left: 50%;
right: 50%;
-moz-transition: left 0.15s ease-in,right 0.15s ease-in;
-o-transition: left 0.15s ease-in,right 0.15s ease-in;
-webkit-transition: left 0.15s ease-in,right 0.15s ease-in;
transition: left 0.15s ease-in,right 0.15s ease-in;
}
/* Responsive: Small Desktop */
#media (max-width: 640px) {
}
/* Responsive: Mobile */
#media (max-width: 640px) {
.frame{
display: none !important;
}
.pageCont{
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.menuIcon{
display: none !important;
}
.centre-div{
width: 90%;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body>
<!--<div class="preloader"></div>-->
<div class="menuIcon" id="profile"></div>
<div class="menuIcon" id="cv"></div>
<div class="menuIcon" id="work"></div>
<div class="menuIcon" id="contact"></div>
<div class="frame rightFrame" id="right"></div>
<div class="frame leftFrame" id="left"></div>
<div class="frame topFrame" id="top"></div>
<div class="frame bottomFrame" id="bottom"></div>
<div class="pageCont home">
<div class="centre-div">
<img class="profile-pic" src="img/me_1#2x.png">
<h2 class="home">Hi, I'm Gavin.</h2>
<p class="home">
A graphic and UX designer with excellent communication and design skills with a proven record of delivering creative and innovative design solutions. Welcome to my online Portfolio.
</p>
<p class="home">
I have passion for both digital and print design, with a forward-thinking mentality and innovative spark. Please feel free to have a <a>look around</a> and <a>say hello</a>.
</p>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="js/gavinfriel.js" type="text/javascript"></script>
</body>
I need my slider box to be about 5 times bigger and I have no idea how to do it. How do I go about making the slider box bigger? I did not want to use jQuery so I am only using CSS and HTML . I have tried increasing the width but that has not helped anything
h1 {color:#333; text-shadow:1px 1px #999; font-size:40px; margin:40px; text-align:center;}
.slider {
display: block;
/*min and max changes size of slider?*/
height: 320px;
min-width: 260px;
max-width: 640px;
margin: auto;
margin-top: 20px;
position: relative;
}
.sliderinner {
width: 100%;
height: 100%;
overflow: hidden;
position: relative;
}
.sliderinner>ul {
list-style: none;
height: 100%;
width: 500%;
overflow: hidden;
position: relative;
left: 0px;
}
.sliderinner>ul>li {
width: 20%;
height: 320px;
float: left;
position: relative;
}
.sliderinner>ul>li>img {
margin: auto;
height: 100%;
}
.slider input[type=radio] {
position: absolute;
left: 50%;
bottom: 150px;
z-index: 100;
visibility: hidden;
}
.slider label {
position: absolute;
left: 50%;
bottom: -45px;
z-index: 100;
width: 12px;
height: 12px;
background-color:#ccc;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
cursor: pointer;
-webkit-box-shadow: 0px 0px 3px rgba(0,0,0,.8);
-moz-box-shadow: 0px 0px 3px rgba(0,0,0,.8);
box-shadow: 0px 0px 3px rgba(0,0,0,.8);
-webkit-transition: background-color .2s;
-moz-transition: background-color .2s;
-o-transition: background-color .2s;
transition: background-color .2s;
}
.slider input[type=radio]#control1:checked~label[for=control1] { background-color: #333; }
.slider input[type=radio]#control2:checked~label[for=control2] { background-color: #333; }
.slider input[type=radio]#control3:checked~label[for=control3] { background-color: #333; }
.slider input[type=radio]#control4:checked~label[for=control4] { background-color: #333; }
.slider input[type=radio]#control5:checked~label[for=control5] { background-color: #333; }
.slider label[for=control1] { margin-left: -36px }
.slider label[for=control2] { margin-left: -18px }
.slider label[for=control4] { margin-left: 18px }
.slider label[for=control5] { margin-left: 36px }
.slider input[type=radio]#control1:checked~.sliderinner>ul { left: 0 }
.slider input[type=radio]#control2:checked~.sliderinner>ul { left: -100% }
.slider input[type=radio]#control3:checked~.sliderinner>ul { left: -200% }
.slider input[type=radio]#control4:checked~.sliderinner>ul { left: -300% }
.slider input[type=radio]#control5:checked~.sliderinner>ul { left: -400% }
.description {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
z-index: 1000;
}
.description-text {
background-color: rgba(0,0,0,.8);
padding:10px;
top: 0;
z-index: 4;
-webkit-transition: opacity .2s;
-moz-transition: opacity .2s;
-o-transition: opacity .2s;
transition: opacity .2s;
color: #fff;
}
.slider {
display: block;
/*min and max changes size of slider?*/
height: 320px;
min-width: 260px;
max-width: 640px;
margin: auto;
margin-top: 20px;
position: relative;
}
The above code does not set a fixed height/width, so it will most likely inherit it's size based on it's content. To set a fixed height and width: change your code to the following:
.slider {
display: block;
/*min and max changes size of slider?*/
height: 320px;
min-width: 260px;
max-width: 640px;
height: //specified height
width: //specified width
margin: auto;
margin-top: 20px;
position: relative;
}
Code added:
height: //specified height
width: //specified width
EDIT:
I now see that you have a fixed height in there. To make it bigger, just increase your height and/or add a fixed width.
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
Right now I'm doing this to animate an element background color.
<style>
.container{
padding: 30px;
}
.element {
position: relative;
font-size: 20px;
line-height: 20px;
background-color: #c00;
display: inline-block;
overflow: hidden;
}
.element div {
position: absolute;
top: -20px;
left: 0;
background-color: #0c0;
transition:top 0.5s ease;
}
.element:hover div {
top: 0px;
transition:top 0.5s ease;
}
</style>
<div class="container">
<div class="element">some text<div>some text</div></div>
</div>
JsFiddle demo.
Is there any "cleaner" way to have the same animation? Right now I'm duplicating my content to achieve this.
You can use pseudo elements for this, and not have to duplicate any content:
It's basically moving one pseudo from above the element, and bringing it down over the element on the hover
div {
position: relative;
display: inline-block;
overflow: hidden;
}
div:before,
div:after {
content: "";
position: absolute;
left: 0;
height: 100%;
width: 100%;
transition: all 0.6s;
z-index: -1;
}
div:before {
top: 0;
background: red;
}
div:after {
top: -100%;
background: green;
}
div:hover:before {
top: 100%;
}
div:hover:after {
top: 0;
}
<div>Text? Why would you ever want text?</div>
If you want the text to 'move' as well, you can do something similar:
div {
position: relative;
display: inline-block;
overflow: hidden;
height:20px;
width:300px;
}
div:before,
div:after {
content: attr(data-text);
position: absolute;
left: 0;
height: 100%;
width: 100%;
transition: all 0.6s;
z-index: -1;
}
div:before {
top: 0;
background: red;
}
div:after {
top: -100%;
background: green;
}
div:hover:before {
top: 100%;
}
div:hover:after {
top: 0;
}
<div data-text="Text? Why would you ever want text?"></div>
Note: canIuse suggests it is widely supported (bit I admit only tested in latest chrome, so only going by this for cross browser). However, This may affect SEO, and so I would be reluctant to use this in production.
If you just wanted the 'upper' element to flow over the top of the text (instead of 'lower' text scrolling as well), You could do:
div {
position: relative;
display: inline-block;
overflow: hidden;
height: 20px;
width: 300px;
background: red;
}
div:before {
content: attr(data-text);
position: absolute;
left: 0;
height: 100%;
width: 100%;
transition: all 0.6s;
top: -100%;
background: green;
}
div:hover:before {
top: 0;
}
<div data-text="The text I always wanted">The text I always wanted</div>
You could do it with background-position
Set a linear-gradient to 50% of each of the background colors and set the background size to be 200% of the actual div.
Then animate it and move the background 100% up. Like this:
.container {
padding: 30px;
}
.element {
position: relative;
font-size: 20px;
line-height: 20px;
background-color: #c00;
display: inline-block;
overflow: hidden;
background-size: 100% 200%;
background-image: linear-gradient(to bottom, #c00 50%, #0c0 50%);
}
.element:hover {
background-position: 0 -100%;
transition: background-position 1s;
}
<div class="container">
<div class="element">some text</div>
</div>
This cuts out the need for any duplicate content in either the css or the html.
Yes, you can use pseudo element :before and get the text with attribute like:
<div class="container">
<div class="element" data-text="some text">some text</div>
</div>
And css:
.container{
padding: 30px;
}
.element {
position: relative;
font-size: 20px;
line-height: 20px;
background-color: #c00;
display: inline-block;
overflow: hidden;
}
.element:before {
content: attr(data-text);
position: absolute;
top: -20px;
left: 0;
background-color: #0c0;
transition:top 0.5s ease;
}
.element:hover:before {
top: 0px;
transition:top 0.5s ease;
}
http://jsfiddle.net/Pik_at/g3Lxrou4/3/
just similar to jbutler483, but using just a single pseudo class. FIDDLE
.container {
padding: 30px;
}
.element {
position: relative;
font-size: 20px;
line-height: 20px;
background-color: #c00;
display: inline-block;
transition: top 0.5s ease;
overflow: hidden;
}
.element:after {
position: absolute;
top: -60px;
content: 'some text';
font-size: 20px;
line-height: 20px;
left: 0;
display: inline-block;
background-color: #0c0;
transition: top 0.5s ease;
}
.element:hover:after {
top: 0px;
}
<div class="element">some text</div>