facebook / facebook/stylex

Specifying `@media` at rules and pseudo selectors `:last-child` together

Open
#1,314 6 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
10.3k
Forks
481
Avg merge
3d 8h
Merged PRs (30d)
13

Description

### Describe the issue

So I have the following styles specified:

```ts
const styles = stylex.create({
container: {
marginBottom: {
default: '0.5rem',
'@media screen and (min-width: 800px)': '0.75rem',
':last-child': 0
}
}
})
```

### Expected behavior

I want my `margin-bottom` to always be `0` when as a last child element, otherwise `0.5rem` and `0.5rem` on larger screens. However `':last-child'` never works on larger screen. I'd like to know the proper way to do so.

### Steps to reproduce

```tsx
import * as stylex from '@stylexjs/stylex';

const styles = stylex.create({
container: {
marginBottom: {
default: '0.5rem',
'@media screen and (min-width: 800px)': '0.75rem',
':last-child': 0
}
}
});



Hello!


Hello!


Hello!


```

### Test case

_No response_

### Additional comments

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.