Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can CSS do a conditional max-width or min-width for objects themselves?

Tags:

css

Without using JavaScript, is there a way in CSS to say something like "whitespace: nowrap" specifically for td but only if the td has a max-width of a certain size?

I know you can do @media to do css only for certain screen sizes. I want to have the css only apply when a particular object is a certain size.

like image 635
wolftune Avatar asked Apr 25 '26 23:04

wolftune


1 Answers

You would need JavaScript to do exactly what you want, but there is a possibility:

Let's say that you applied a class to some <td>s:

<td class="changed">...</td>
<td>...</td>
<td>...</td>
<td>...</td>
<td class="changed">...</td>
<td>...</td>

And you gave .changed a certain max-width:

.changed {
    max-width: 100px;
}

Then, you would be able to do what you want:

td:not(.changed) {
    /*Some styling*/
}
like image 97
Anonymous Avatar answered Apr 27 '26 19:04

Anonymous



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!