Páricsi Zoltán Páricsi Zoltán - 9 months ago 35
CSS Question

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

I want to set

<div class="first">
, only if there's no
<div class="second">

Do you have any idea how to do it?

Answer Source

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.