最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to use ng-deep at media query syntax inside? - Stack Overflow

programmeradmin1浏览0评论

I need to bind the CSS class property value dynamically for desktop. i have using ng-deep in angular. if i use the ng-deep inside the @media query is not working.

i have tried below code in css

 @media (min-width: 1025px) and (max-width: 1280px) {

   ::ng-deep.bs-datepicker {
    left: var(--my-var) !important;
   }

  }

ng-deep CSS is not working at media query syntax. where i need to place or what i need to do?

I need to bind the CSS class property value dynamically for desktop. i have using ng-deep in angular. if i use the ng-deep inside the @media query is not working.

i have tried below code in css

 @media (min-width: 1025px) and (max-width: 1280px) {

   ::ng-deep.bs-datepicker {
    left: var(--my-var) !important;
   }

  }

ng-deep CSS is not working at media query syntax. where i need to place or what i need to do?

Share Improve this question edited Mar 16, 2022 at 22:20 Akber Iqbal 15k12 gold badges53 silver badges75 bronze badges asked Jul 23, 2019 at 10:42 ManikandanManikandan 511 silver badge11 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

::ng-deep does work inside a media query... something else must be off for your specific case;

relevant CSS in typeahead-basic.ts:

  ::ng-deep .dropdown-menu.show { background:lightblue;}
  ::ng-deep .dropdown-item { color:red !important; }
  @media screen and (max-width:768px){
    ::ng-deep .dropdown-menu.show { background:lightgreen;}
    ::ng-deep .dropdown-item { color:orange !important; }
  }

plete working stackblitz here

update: for your shared stackblitz, the correct syntax is below... you gotta check your page on the widths between 1025px and 1280px and you will see the effect in action:

@media  (min-width:1025px) and (max-width: 1280px) {

::ng-deep .third-party-content{
  left:30px;
  position: absolute;
  color:red;
}

}

I just found out you can do it like this in scss

::ng-deep.bs-datepicker {
  @media  (min-width:1025px) and (max-width: 1280px) {
    left:30px;
    position: absolute;
    color:red;
  }
}

I might be late to the conversation but eh, If you still need it or anyone else like me still looking... I hope it works for you too :)

发布评论

评论列表(0)

  1. 暂无评论