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>
Related
I'm trying to get the border on my button to appear, it works perfectly with solid background colors but not with a image . You can see the border when clicking on the button but not when mouse over it.
I just want the border to be visible.
<html lang="en"> <head>
<style>
#import url(https://fonts.googleapis.com/css?family=Montserrat);
*, *::after, *::before {
box-sizing: border-box;
}
body {
{ background-image: url("https://cdn.pixabay.com/photo/2016/09/05/15/07/concrete-1646788_960_720.jpg") }
}
.container {
display: flex;
flex-direction: column;
justify-content: center;
height: 100vh;
width: 100vw;
text-align: center;
}
button {
font-family: "Montserrat", sans-serif;
text-transform: uppercase;
}
button {
position: relative;
border: none;
font-size: 18px;
transition: color 0.5s, transform 0.2s, background-color 0.2s;
outline: none;
border-radius: 3px;
margin: 0 10px;
padding: 23px 33px;
border: 3px solid transparent;
}
button:active {
transform: translateY(3px);
}
button::after, button::before {
border-radius: 3px;
}
.shrink-border {
background-color: transparent;
color: #1b1b20;
}
.shrink-border:hover {
background-color: transparent;
box-shadow: none;
color: #E3BD1C;
}
.shrink-border::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 3px solid #1b1b20;
transition: opacity 0.3s, border 0.3s;
}
.shrink-border:hover::before {
opacity: 0;
}
.shrink-border::after {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: transparent;
border: 3px solid #E3BD1C;
opacity: 0;
z-index: -1;
transform: scaleX(1.1) scaleY(1.3);
transition: transform 0.3s, opacity 0.3s;
}
.shrink-border:hover::after {
opacity: 1;
transform: scaleX(1) scaleY(1);
}
.material-bubble {
background-color: transparent;
color: #EEC02C;
border: 3px solid #EEC02C;
overflow: hidden;
box-shadow: none;
}
.material-bubble:hover {
color: #EEC02C;
}
.material-bubble::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 3px solid #EEC02C;
transition: opacity 0.3s, border 0.3s;
}
.material-bubble:hover::before {
opacity: 0;
}
.material-bubble::after {
content: "";
position: absolute;
top: 0;
left: 0;
width: 200px;
height: 200px;
background-color: #EEC02C;
border-color: #EEC02C;
border-radius: 50%;
transform: translate(-10px, -70px) scale(0.1);
opacity: 0;
z-index: -1;
transition: transform 0.3s, opacity 0.3s, background-color 0.3s;
}
.material-bubble:hover::after {
opacity: 1;
transform-origin: 100px 100px;
transform: scale(1) translate(-10px, -70px);
}
</style>
</head>
<body translate="no">
<div class="container">
<div>
<div style="background-image: url('https://cdn.pixabay.com/photo/2016/09/05/15/07/concrete-1646788_960_720.jpg');">
<a href="https://sites.google.com/u/0/d/1qexyDxBEpBgUx3IVqODoqfLs59AG0eV1/p/1SsjI8NaKooq171w4dA5LW0NvxKX9ACkG/preview?authuser=0">
<button class="shrink-border">Make an Appointment</button>
</a>
</a>
</div>
</div>
</body></html>
Just add a z-index to your border:
.shrink-border {
background-color: transparent;
color: #1b1b20;
z-index: 0; /* <--- Add this */
}
Full working Demo:
<html lang="en"> <head>
<style>
#import url(https://fonts.googleapis.com/css?family=Montserrat);
*, *::after, *::before {
box-sizing: border-box;
}
body {
{ background-image: url("https://cdn.pixabay.com/photo/2016/09/05/15/07/concrete-1646788_960_720.jpg") }
}
.container {
display: flex;
flex-direction: column;
justify-content: center;
height: 100vh;
width: 100vw;
text-align: center;
}
button {
font-family: "Montserrat", sans-serif;
text-transform: uppercase;
}
button {
position: relative;
border: none;
font-size: 18px;
transition: color 0.5s, transform 0.2s, background-color 0.2s;
outline: none;
border-radius: 3px;
margin: 0 10px;
padding: 23px 33px;
border: 3px solid transparent;
}
button:active {
transform: translateY(3px);
}
button::after, button::before {
border-radius: 3px;
}
.shrink-border {
background-color: transparent;
color: #1b1b20;
z-index: 0; /* <--- Add this */
}
.shrink-border:hover {
background-color: transparent;
box-shadow: none;
color: #E3BD1C;
}
.shrink-border::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 3px solid #1b1b20;
transition: opacity 0.3s, border 0.3s;
}
.shrink-border:hover::before {
opacity: 0;
}
.shrink-border::after {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: transparent;
border: 3px solid #E3BD1C;
opacity: 0;
z-index: -1;
transform: scaleX(1.1) scaleY(1.3);
transition: transform 0.3s, opacity 0.3s;
}
.shrink-border:hover::after {
opacity: 1;
transform: scaleX(1) scaleY(1);
}
.material-bubble {
background-color: transparent;
color: #EEC02C;
border: 3px solid #EEC02C;
overflow: hidden;
box-shadow: none;
}
.material-bubble:hover {
color: #EEC02C;
z-index: -1;
}
.material-bubble::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 3px solid #EEC02C;
transition: opacity 0.3s, border 0.3s;
}
.material-bubble:hover::before {
opacity: 0;
}
.material-bubble::after {
content: "";
position: absolute;
top: 0;
left: 0;
width: 200px;
height: 200px;
background-color: #EEC02C;
border-color: #EEC02C;
border-radius: 50%;
transform: translate(-10px, -70px) scale(0.1);
opacity: 0;
z-index: -1;
transition: transform 0.3s, opacity 0.3s, background-color 0.3s;
}
.material-bubble:hover::after {
opacity: 1;
transform-origin: 100px 100px;
transform: scale(1) translate(-10px, -70px);
}
</style>
</head>
<body translate="no">
<div class="container">
<div>
<div style="background-image: url('https://cdn.pixabay.com/photo/2016/09/05/15/07/concrete-1646788_960_720.jpg');">
<a href="https://sites.google.com/u/0/d/1qexyDxBEpBgUx3IVqODoqfLs59AG0eV1/p/1SsjI8NaKooq171w4dA5LW0NvxKX9ACkG/preview?authuser=0">
<button class="shrink-border">Make an Appointment</button>
</a>
</a>
</div>
</div>
</body></html>
Add this to your css
.shrink-border:hover {
transform: translateY(3px);
}
In my code, the left border should be removed after .6s even when the cursor is still(hover) on the button
.button {
position: relative;
box-shadow: 0 0 10px rgba(0,0,0,0.5);
padding: 10px 20px;
text-decoration: none;
color: inherit;
font-size: 20px;
}
.button::after {
content: "";
position: absolute;
left: 0;
top: 0;
bottom: 0;
height: 0%;
border-left: 1.5px solid black;
transition: 0.6s;
}
.button:hover:after {
transition: .6s;
height: 100%;
/*After hover(after.6s), height should be 0%*/
}
You can use callback function to fetch the end of a transition/animation.
Check out this article:
https://betterprogramming.pub/detecting-the-end-of-css-transition-events-in-javascript-8653ae230dc7
As suggested by #prettyInPink, Here is how you can use keyframes.
.button {
position: relative;
box-shadow: 0 0 10px rgba(0,0,0,0.5);
padding: 10px 20px;
text-decoration: none;
color: inherit;
font-size: 20px;
}
.button::after {
content: "";
position: absolute;
left: 0;
top: 0;
bottom: 0;
height: 0%;
border-left: 1.5px solid black;
transition: 0.6s;
}
.button:hover:after {
/**
Added 1.2s to smoothly hide the border
From 0%-50% - .6s
From 50%-100% - .6s
**/
animation: borderAnim 1.2s ease-in-out forwards;
}
#keyframes borderAnim {
0% {
opacity: 1;
height: 0%;
}
50% {
opacity: 1;
height: 100%;
}
100% {
height: 100%;
opacity: 0;
}
}
<button class="button">My Button</button>
I am trying to create a skill bar where the background color of the progress slides in but the label for the Skill bar stays in the same place.
.skill-container * {
box-sizing: border-box;
}
.skill-container {
width: 100%;
border-radius: 5px;
background-color: lightgray;
margin: 20px 0;
overflow: hidden;
}
.skill-container .skill {
display: inline-block;
text-align: left;
color: white;
padding: 10px 0 10px 4px;
border-radius: inherit;
background-color: #312E81;
white-space: nowrap;
position: relative;
animation: animateLeft 1s ease-out;
}
#keyframes animateLeft {
from {
left: -100%
}
to {
left: 0
}
}
.skill-container .skill.skill-level-70 {
width: 70%
}
<div class="skill-container">
<span class="skill skill-level-70">CSS</span>
</div>
So far the animation works well, but the only thing I need to figure out is how to keep the text (CSS) on the left and animate the sliding of the background color to show the progress
Use a pseudo element for the background:
.skill-container .skill {
color: white;
background-color: lightgray;
margin: 5px 0;
padding: 10px 0 10px 4px;
overflow: hidden;
border-radius: 5px;
white-space: nowrap;
position: relative;
z-index:0;
}
.skill-container .skill::before {
content: "";
position: absolute;
background-color: #312E81;
border-radius: inherit;
z-index: -1;
top: 0;
bottom: 0;
left: 0;
animation: animateLeft 1s ease-out;
}
#keyframes animateLeft {
from {
transform: translateX(-100%);
}
}
.skill-container .skill.skill-level-70::before {
width: 70%
}
.skill-container .skill.skill-level-40::before {
width: 40%
}
.skill-container .skill.skill-level-100::before {
width: 100%
}
<div class="skill-container">
<div class="skill skill-level-100">CSS</div>
<div class="skill skill-level-70">HTML</div>
<div class="skill skill-level-40">PHP</div>
</div>
You can optimize with CSS variables:
.skill-container .skill {
color: white;
background-color: lightgray;
margin: 5px 0;
padding: 10px 0 10px 4px;
overflow: hidden;
border-radius: 5px;
white-space: nowrap;
position: relative;
z-index:0;
}
.skill-container .skill::before {
content: "";
position: absolute;
background-color: #312E81;
border-radius: inherit;
z-index: -1;
top: 0;
bottom: 0;
left: 0;
width:var(--l,0%);
animation: animateLeft 1s ease-out;
}
#keyframes animateLeft {
from {
transform: translateX(-100%);
}
}
<div class="skill-container">
<div class="skill" style="--l:100%">CSS</div>
<div class="skill" style="--l:70%">HTML</div>
<div class="skill" style="--l:40%">PHP</div>
</div>
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'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.