How to make this background-image responsive - html

I'm trying to make my "Icon_POS_bitmap.png" responsive. If I view the Website on a laptop, the image is cut off at the bottom. I know i can't put the .hero-slides .single-hero-slides on a fixed 1000px height. But height: 100%; and height: auto; doesn't seem to work.
When I try to set things on auto or 100%, the image disappears and the following div "sonar-project-areas" goes at the top.
HTML
<section class="hero-area">
<div class="hero-slides">
<!-- Single Hero Slide -->
<div class="single-hero-slide bg-img slide-background-overlay" style="background-image: url(img/bg-img/Icon_POS_bitmap.png);">
</div>
</div>
</section>
CSS
.hero-slides .single-hero-slide {
height: 1000px;
width: 100%;
position: relative;
z-index: 1;
-webkit-transition-duration: 800ms;
transition-duration: 800ms;
overflow: visible;
/*cursor: pointer; */
}
.hero-slides .single-hero-slide .hero-slides-content {
position: relative;
z-index: 1;
-webkit-transform: translateY(75%);
transform: translateY(75%);
-webkit-transition-duration: 800ms;
transition-duration: 800ms;
bottom: 0;
}
.hero-slides .single-hero-slide .hero-slides-content .line {
width: 100px;
height: 1px;
background-color: #ffffff;
margin-bottom: 30px;
display: block;
}
.hero-slides .single-hero-slide .hero-slides-content h2 {
color: #ffffff;
font-weight: 100;
}
.hero-slides .single-hero-slide .hero-slides-content p {
color: #ffffff;
margin-bottom: 0;
-webkit-transition-duration: 500ms;
transition-duration: 500ms;
margin-top: 140px;
}
.hero-slides .single-hero-slide:hover .hero-slides-content {
-webkit-transform: translateY(0%);
transform: translateY(0%);
}
.hero-slides .single-hero-slide:hover p {
margin-top: 40px;
}
.bg-img {
background-position: center center;
background-size: cover;
background-repeat: no-repeat;
}
.slide-background-overlay {
position: relative;
z-index: 1;
bottom: 0;
left: 0;
width: 100%;
height: 60%;
}
.slide-background-overlay::after {
content: '';
position: absolute;
height: 60%;
width: 100%;
z-index: -1;
bottom: 0;
left: 0;
}
The original Template i use is this: https://colorlib.com/wp/template/sonar/
I modify it for my needs.
I use html/css/js from time to time but i can't find the issue.
Greetings Adrian

This is what you're trying to do, I added height: 100vh to the main container and moved the style="background: ...." inside the css in .bg-img . I also added margin: 0; padding: 0 to the body
body {
margin: 0;
paddong: 0;
}
.hero-slides .single-hero-slide {
height: 100vh;
/* You can change this to 50vh (50% of the screen width) and will still be responsive */
width: 100%;
position: relative;
z-index: 1;
-webkit-transition-duration: 800ms;
transition-duration: 800ms;
overflow: visible;
/*cursor: pointer; */
}
.hero-slides .single-hero-slide .hero-slides-content {
position: relative;
z-index: 1;
-webkit-transform: translateY(75%);
transform: translateY(75%);
-webkit-transition-duration: 800ms;
transition-duration: 800ms;
bottom: 0;
}
.hero-slides .single-hero-slide .hero-slides-content .line {
width: 100px;
height: 1px;
background-color: #ffffff;
margin-bottom: 30px;
display: block;
}
.hero-slides .single-hero-slide .hero-slides-content h2 {
color: #ffffff;
font-weight: 100;
}
.hero-slides .single-hero-slide .hero-slides-content p {
color: #ffffff;
margin-bottom: 0;
-webkit-transition-duration: 500ms;
transition-duration: 500ms;
margin-top: 140px;
}
.hero-slides .single-hero-slide:hover .hero-slides-content {
-webkit-transform: translateY(0%);
transform: translateY(0%);
}
.hero-slides .single-hero-slide:hover p {
margin-top: 40px;
}
.bg-img {
background-image: url("https://picsum.photos/5472/3648?image=1074");
background-position: center center;
background-size: cover;
background-repeat: no-repeat;
}
.slide-background-overlay {
position: relative;
z-index: 1;
bottom: 0;
left: 0;
width: 100%;
height: 60%;
}
.slide-background-overlay::after {
content: "";
position: absolute;
height: 60%;
width: 100%;
z-index: -1;
bottom: 0;
left: 0;
}
<section class="hero-area">
<div class="hero-slides">
<!-- Single Hero Slide -->
<div class="single-hero-slide bg-img slide-background-overlay">
</div>
</div>
</section>

You seem to be trying to create a responsive background image. If that's the case, you'll find below a quick hint on how to do it.
Responsive image background:
We first create a container for the background like you did with <div class="single-hero-slide bg-img slide-background-overlay"></div>
Next, you set an height and/or a width with width and height CSS properties
After that, select an image to use as background and use background-size: cover or contain
.bg-img {
width: 30vw;
height: 100vh;
background: url('https://images.pexels.com/photos/1034677/pexels-photo-1034677.jpeg?cs=srgb&dl=adult-art-man-1034677.jpg&fm=jpg');
background-size: cover;
}
<div class="single-hero-slide bg-img slide-background-overlay"></div>
Here is a reference of this property : https://developer.mozilla.org/en-US/docs/Web/CSS/background-size

Related

How can i show text from the bottom on hover?

I cannot figure out how to fixate the first part of the text and to make it show from the bottom
on the left is the hover that slides from the bottom and on the right is how it should look like in the beginning
Ive put the code I tried to use inside - please take a look
Thank you!
.container {
padding: 1em 0;
float: left;
width: 50%;
}
.image1 {
display: block;
width: 100%;
height: auto;
transition: all 0.5s ease;
opacity: 1;
backface-visibility: hidden;
}
.middle {
background: rgb(30, 30, 36);
font-weight: 400;
font-size: 16px;
line-height: 22px;
color: rgb(246, 244, 234);
margin: 0px;
}
.middle:hover {
transition: all 0.3s ease-in-out 0s;
opacity: 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
text-align: center;
}
.product-box {
overflow: hidden;
}
.product-box:hover img {
transform: scale(1.04);
transition: all 0.8s linear;
}
.product-box:hover {
background: rgba(30, 30, 36, 0.6) !important;
}
.product-box:hover .image1 {
opacity: 0.5;
background: transparent;
}
.product-box:hover .middle {
opacity: 1;
}
.fadeIn-bottom {
top: 80%;
}
<div class="container">
<div class="product-box fadeIn-bottom" style="margin-top: 20px;">
<img src="https://phpmysqlappdiag454.blob.core.windows.net/blob/assets/images/hotelkos/Rectangle 14.png" alt="" data-filename="1.png" style="width: 100%; height: auto; margin-bottom: -40px;" class="image1">
<div class="middle ">
<p style="color: #F6F4EA;">Suites</p>
</div>
<div>
</div>
What you have to do is put the relative, i.e. the product-box in a relative position, then set the absolute position to the "title" to which you want to apply the transition. Once this is done, you need to know how to use transitions and how absolute position works. These two things are important enough to make several cool and simple animations so I recommend you to check them out.
.product-box {
position: relative;
}
.image1 {
width: 100%;
height: 100%;
}
.title {
position: absolute;
bottom: 0;
left: 0;
right: 0;
top: 90%;
display: flex;
justify-content: center;
align-items: center;
background: rgba(0, 0, 0, .5);
color: white;
transition: all .5s;
}
.product-box:hover .title {
top: 0;
}
<div class="container">
<div class="product-box">
<div class="title">
<h4>Suites</h4>
</div>
<img src="https://phpmysqlappdiag454.blob.core.windows.net/blob/assets/images/hotelkos/Rectangle 14.png" alt="" data-filename="1.png" class="image1">
<div>
</div>
I assume this is what you want;
.container {
width: 50%;
}
.image1 {
width: 100%;
aspect-ratio: 1/1;
object-fit: cover;
transition: all 0.5s ease;
opacity: 1;
}
.product-box {
display: flex;
position: relative;
}
.middle {
position: absolute;
width: 100%;
color: #F6F4EA;
background: rgb(30, 30, 36);
font-weight: 400;
font-size: 16px;
line-height: 22px;
margin: 0px;
text-align: center;
padding-top: 10px;
padding-bottom: 10px;
font-family: sans-serif;
display: flex;
bottom: 0;
justify-content: center;
align-items: center;
}
.product-box:hover {
transform: scale(1.04);
transition: all 0.8s linear;
}
.product-box:hover .middle {
opacity: 0.8;
height: 100%;
padding: 0;
}
<div class="container">
<div class="product-box">
<img src="https://phpmysqlappdiag454.blob.core.windows.net/blob/assets/images/hotelkos/Rectangle 14.png" alt="" class="image1">
<div class="middle">Suites</div>
</div>
</div>

make overlay same width/size as image

I need the hover overlay to be the same width as the image. All the images with that overlay effect are different sizes, but use the same classes.
I found answers to a similar problem, but they all include that I need to have the css “absolute” and “relative” properties the other way around. Which I tried, but it made the hover effect stop working.
Any help with this issue would be very much appreciated.
Thanks, Helene
P.S.:Just so you know, I’m fairly new to coding and I’m not an english native speaker…
<!-- HTML mark-up -->
<div class="container">
<a href="#img1">
<img src="resources/img/hgdgdg_TH1.jpg" class="thumbnail" id="linathi_1">
<div class="overlay">
<div class="caption"><i class="ion-ios-pricetag"> €150</i></div>
</div>
</a>
</div>
/* CSS OVERLAY ON HOVER */
.container {
position: relative;
width: 100% /*50%*/;
}
.thumbnail /* image */ {
display: block;
width: 100%;
height: auto;
}
.overlay {
position: absolute;
bottom: 100%;
left: 0;
right: 0;
background-color: rgba(180, 81, 64, 0.85);
overflow: hidden;
width: 100%;
height: 0;
-webkit-transition: .5s ease;
transition: .5s ease;
}
.container:hover .overlay {
bottom: 0;
height: 100%;
}
.caption {
white-space: nowrap;
font-family: 'Assistant', 'Arial', sans-serif;
font-style: normal;
font-size: 130%;
color: #fff;
position: absolute;
overflow: hidden;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
width: 100%;
text-align: center;
}
<div class="container">
<a href="#img1">
<img src="https://www.w3schools.com/css/img_fjords.jpg" class="thumbnail" id="linathi_1">
<div class="overlay">
<div class="caption"><i class="ion-ios-pricetag"> €150</i></div>
</div>
</a>
/* CSS OVERLAY ON HOVER */
.container {
position: relative;
width: 100%
}
.thumbnail /* image */ {
display: block;
width: 100%;
height: auto;
overflow:hidden;
}
.overlay {
position: absolute;
height: 100%;
width: 100%;
top: 0;
left: 0;
background-color: rgba(180, 81, 64, 0.85);
opacity:0.5;
visibility: hidden;
transition: all .5s ease;
transform: translateY(-100%);
}
.container:hover .overlay,
.container:hover .overlay .caption i {
opacity: 1;
visibility: visible;
transform: translateY(0);
}
.container:hover .overlay .caption i {
transition-delay: 300ms;
}
.caption {
font-family: 'Assistant', 'Arial', sans-serif;
font-style: normal;
font-size: 18px;
color: #fff;
position: absolute;
margin:auto;
overflow: hidden;
top: 0;
left: 0;
width: 100%;
height: 100%;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
}
.caption i {
opacity: 0;
visibility: hidden;
display: inline-block;
transform: translateY(-20px);
transition: all .5s ease;
}

Transition on leaving mouse

I'm trying to make some transition.
At the moment my block has 3 parts :
base block
Hover image (coming from top)
Hover title (coming from bot)
On mouse hover, there also is a transition on the background-color that will change.
Everything works when mouse arrives, and the goal is to make the same inverse animation when the cursor leaves.
#studio {
margin-top:50px;
margin-left:50x;
}
#studio #portfolie {
position: relative;
z-index: 10;
}
#studio #portfolie .content-porfolio {
text-align: center;
width: 800px;
margin: 0 auto 140px;
}
#studio #portfolie .project-title--hover {
bottom: -19px;
transition: bottom .7s ease;
}
#studio #portfolie .project-logo--hover {
margin-top: -100px;
transition: margin-top 0.7s ease;
}
#studio #portfolie .md-trigger:hover .project-title--hover {
display: block !important;
bottom: 25px;
}
#studio #portfolie .md-trigger:hover .project-logo--hover {
display: block !important;
width: 70%;
margin-left: 15%;
height: 100px;
background-repeat: no-repeat;
margin-top: calc((25%-attr(height))/2);
background-size: contain;
background-position: center;
position: absolute;
overflow: hidden;
}
#studio #portfolie .project-logo--base {
height: 100%;
width: 100%;
background-repeat: repeat;
position: absolute;
overflow: hidden;
}
#studio #portfolie .hover-container {
transition: background-color 0.5s ease;
background-color: transparent;
}
#studio #portfolie .md-trigger:hover .hover-container {
background-color: #F1CE34;
height: 100%;
width: 100%;
position: absolute;
}
#studio #portfolie .content-play {
margin-bottom: 15px;
position: relative;
z-index: 2;
}
#studio #portfolie .content-play .slide {
display: none;
}
#studio #portfolie .content-play > * {
width: calc(100% * 1 / 3 - 40px);
}
#studio #portfolie .content-play .play {
height: 200px;
cursor: pointer;
position: relative;
color: #FFF;
text-transform: uppercase;
margin-bottom: 40px;
}
#studio #portfolie .content-play .play span {
font-size: 0.8em;
position: absolute;
font-family: 'ProximaNovaA-Black';
left: 50%;
-webkit-transform: translateX(-50%);
-moz-transform: translateX(-50%);
-ms-transform: translateX(-50%);
-o-transform: translateX(-50%);
transform: translateX(-50%);
display: block;
width: 100%;
}
<section id="studio">
<div id="portfolie">
<ul class="content-play clearfix grid-3">
<li data-modal="modal-video-1" class="first play md-trigger slide" id="first-play" style="display: list-item;">
<div class="project-logo--base" style="background-image: url(http://storage.tvanouvelles.ca/v1/dynamic_resize/sws_path/tvanouvelles_prod/bc7caa6d-8748-495c-8522-a7fc17513ce7_ORIGINAL.jpg?quality=80&size=800x&version=0)">
<div class="hover-container">
<div class="project-logo--hover" style="background-image: url(http://www.esoterisme-exp.com/File_images/2012/1205/Carre-bleu.png)"></div>
<span class="project-title--hover">Tennis festival</span>
</div>
</div>
</li>
</ul>
</div>
</section>
here is the same on CodePen because it looks easier to modify
You could use :not(:hover) pseudo class.
If your problem is that the blue square is not going back up then try it like this:
#studio #portfolie .project-logo--hover {
top: -100px;
transition: top .7s ease;
width: 70%;
margin-left: 15%;
height: 100px;
background-repeat: no-repeat;
background-size: contain;
background-position: center;
position: absolute;
}
#studio #portfolie .md-trigger:hover .project-title--hover {
display: block !important;
bottom: 25px;
}
#studio #portfolie .md-trigger:hover .project-logo--hover {
display: block !important;
top: calc((25%-attr(height))/2);
}
#studio #portfolie .hover-container {
transition: background 0.7s linear;
background-color: #FDF200;
height: 100%;
width: 100%;
position: absolute;
}
#studio #portfolie .md-trigger:hover .hover-container {
background-color: #F1CE34;
}
Have a look at the "Sweep to Top" background-transition here and here. I think it could suit your needs.

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

Dynamically resizing sprite images with CSS

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.