Notes

Adding CSS using jQuery

Edit on GitHub

Web Development

You can add a style using .css()

1jQuery("#popularUsersContainer").css("max-height", "360px")

You can also pass it a styles object (like a React Native stylesheet object) if you want to add multiple values

1let containerStyles = {
2  maxHeight: `${containerHeight}px`,
3  display: 'flex',
4  flexWrap: 'wrap',
5  justifyContent: 'center',
6  overflow: 'hidden'
7};
8
9jQuery("#popularUsersContainer").css(containerStyles)

If you want hover styles, you’ll combine .css() with .hover()

1$("div.myclass").hover(function() {
2  $(this).css("background-color","red")
3});
1$(".myclass, .myclass2").hover(function(e) {
2    $(this).css("background-color",e.type === "mouseenter"?"red":"transparent")
3})