项目作者: FreddyFY

项目描述 :
Use Container Queries [Element Queries] with styled-components
高级语言: JavaScript
项目地址: git://github.com/FreddyFY/styled-container-query.git
创建时间: 2018-09-24T07:41:02Z
项目社区:https://github.com/FreddyFY/styled-container-query

开源协议:MIT License

下载



NPM-Version
NPM-Downloads
NPM-Size
NPM-License

Styled Container Query

Use Container Queries [Element Queries] with styled-components

NPM-Package: styled-container-query

Demo

Installing

  1. npm install styled-container-query --save

Usage

Nothing easier than that. You can use it like styled-components and an element query :container().

  1. import styledContainerQuery from 'styled-container-query';
  2. const Child = styled.span``
  3. const Component = styledContainerQuery.div`
  4. background-color: green;
  5. &:container(min-width: 500px) {
  6. background-color: red;
  7. ${Child} {
  8. color: white;
  9. }
  10. }
  11. &:container(max-width: 600px and max-width: 900px) {
  12. background-color: yellow;
  13. }
  14. &:container(min-height: 500px) {
  15. background-color: blue;
  16. }
  17. &:container(min-width: 50%) {
  18. background-color: blue;
  19. }
  20. `;

Known issues

  • Props inside a container-query does not work. #1

License

MIT License

Copyright © 2019 Freddy Ochner

LICENSE