CSS :has() Multiple Classes

User
.geodir-post-meta-container:has(.geodir-field-latitude)
{
display:none;
}
has for two classes
Assistant
If you want to target elements using the `:has()` pseudo-class for two or more classes, you can combine the conditions inside `:has()` using a comma-separated list. Here's an example for your use case:

.geodir-post-meta-container:has(.geodir-field-latitude, .geodir-field-longitude) {
    display: none;
}

### Explanation:
– `:has()` accepts a selector as its argument.
– The selector `.geodir-field-latitude, .geodir-field-longitude` matches elements with either the `geodir-field-latitude` class **or** the `geodir-field-longitude` class.
– The rule hides `.geodir-post-meta-container` if it contains **at least one** of those elements.

If you need to match both classes **together within the same parent**, you can do this:

.geodir-post-meta-container:has(.geodir-field-latitude):has(.geodir-field-longitude) {
    display: none;
}

This hides the parent only if it contains **both** `.geodir-field-latitude` and `.geodir-field-longitude`.

Leave a Comment

Your email address will not be published. Required fields are marked *