Páricsi Zoltán Páricsi Zoltán - 1 month ago 5
CSS Question

How to set css for first div, if there's no second div

I want to set

border-bottom-left-radius
and
border-bottom-right-radius
for
<div class="first">
, only if there's no
<div class="second">
.

Do you have any idea how to do it?

Answer

It is not possible using CSS only. Here is an example to do it with jQuery:

if ($('.second').length == 0) {
    $('.first').css('border-radius', '0 0 2px 2px');
}

With $('.second').length == 0 you check, wether an element of class second exists or not. You can read more about jQuery's css() function on the documention.