K
K
KyIIpyM2016-04-27 14:45:58
PHP
KyIIpyM, 2016-04-27 14:45:58

News output with two different wordpress styles?

In general, I plan to display news in two different styles, that is:
News 1 has the content-section-a
class News 2 has the content-section-b
class News 3 has the content-section-a
class News 4 has the content-section-b class
And so further around the circle. I can’t figure out how to implement this, and even xs from which side to approach Google, can someone tell me?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Kozlov, 2016-04-27
@trampick

you just need the css property nth-child()
Let's say we have news displayed like this

<div class="items">
<div class="item">Новость 1</div>
<div class="item">Новость 2</div>
<div class="item">Новость 3</div>
<div class="item">Новость 4</div>
<div class="item">Новость 5</div>
</div>

In order to set the style of the first news, you need to do this
.items .item:nth-child(1){
color:red;//перечисляем свойства
}

In order to set the style of the third news, you need to do this
.items .item:nth-child(3){
color:blue;//перечисляем свойства
}

can also be used like this
.items .item:nth-child(2n){
color:blue;//перечисляем свойства
}

it means to set styles for every second element

A
Alexey Ukolov, 2016-04-27
@alexey-m-ukolov

$a % $b Modulo The integer remainder of $a divided by $b.

php.net/manual/en/language.operators.arithmetic.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question