S
S
shapovaloff2018-02-11 22:54:53
css
shapovaloff, 2018-02-11 22:54:53

How to write a css style so that the background changes only for the first and last button?

You need to change the background of all buttons, except for the extreme ones (first and last). How to do it?

<div data-role="buttons">
    <button>1</button>
    <button>2</button>
    <!-- ещё кнопки -->
    <button>8</button>
    <button>9</button>
</div>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikolai Chuprik, 2018-02-11
@choupa

button:not(:first-child):not(:last-child)  {
  background: @yourColor;
}

N
ntcassits, 2018-02-11
@ntcassits

div button {
    background: #f00;
}

div button:first-child {
    background: transparent;
}

div button:last-child {
    background: transparent;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question