I'm looking for CSS rules that allow setting fixed element width (let's say `width: 500px`), but combines it with `max-width: 100%` if a container is narrower than the element.

I'm thinking about something similar to:

```
.elem {
 width: 600px;
 max-width: 100%;
}

```

This snippet works perfect - if a `.elem`'s container is narrower than the `.elem` itself, the `.elem` has container's width - smaller than `600px`.

How to achieve the same effect with `min-width`? The following snippet doesn't work:

```
.elem {
 min-width: 600px;
 max-width: 100%;
}

```

Maybe any ideas using CSS Grid or even JavaScript?