Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Background image #17

Open
markoarsenal opened this issue Oct 6, 2017 · 2 comments
Open

Background image #17

markoarsenal opened this issue Oct 6, 2017 · 2 comments

Comments

@markoarsenal
Copy link

Hi, I often set images as backgrounds, especially when I need specific ratio, maybe mixin for that can look something like this

.thumb-image {
  @util bg-image(/assets/images/awesome-image.jpg);
}
.thumb-image {
  background-image: url(/assets/images/awesome-image.jpg);
  background-position: center;
  background-size: cover;
}

Or maybe in combination with aspect-ratio mixin

.thumb-image {
  @util aspect-ratio(16:9);
  @util bg-image(/assets/images/awesome-image.jpg);
}
@ismamz
Copy link
Owner

ismamz commented Oct 6, 2017

Hi @markoarsenal! It's good idea, but I think that maybe bg-image is not the best name because it could be confused with background-image property.

I suggest something like this:
@util cover('assets/images/awesome-image.jpg');

@markoarsenal
Copy link
Author

You're right about name :) But, I imagined that mixin can also accept other params, for example:

.thumb-image {
  @util bg('assets/images/awesome-image.jpg', top, contain);
}
.thumb-image {
  background-image: url(/assets/images/awesome-image.jpg);
  background-position: top;
  background-size: contain;
}

Maybe also to consider other params for background, those three I use the most.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants