There is a block in which 4 span and a picture. 2 span with the abs classes and the picture are permanent, and 2 span with the rel class can either be present or not, and the picture location should not change from this (should not be shifted!) And if there is no rel-1 block - rel-2 should move in his place. If there are not both rel blocks, the picture goes to the top margin-top:-50px; And this is the main problem. How can this be done with styles or without scripts? here fidl
div { position: relative; width: 350px; height: 150px; } img { margin-top:-50px; } .rel { position: relative; top: 0; left: 0; display: inline-block; width: 50px; height: 50px; background-color: red; } .abs-1, .abs-2 { display: inline-block; width: 50px; height: 50px; background-color: blue; position: absolute; top: 0; } .abs-1 { right: 0; } .abs-2 { right: 55px; } <div> <span class="rel">rel-1</span> <span class="rel">rel-2</span> <img src="http://placehold.it/350x150"> <span class="abs-1">abs-3</span> <span class="abs-2">abs-4</span> </div>
<span class="rel">rel-1</span>? - Grundy<?php $data = get_the_ID(); ?> <span <?php echo "data-id=" . $data; ?> class='quick-view'></span><?php $data = get_the_ID(); ?> <span <?php echo "data-id=" . $data; ?> class='quick-view'></span><?php $data = get_the_ID(); ?> <span <?php echo "data-id=" . $data; ?> class='quick-view'></span>- Vasya