HTML Element Style How to - Change li order with change of resolution








Question

We would like to know how to change li order with change of resolution.

Answer


<!DOCTYPE html>
<html>
<head>
<style>
ul {<!-- w w  w  .  j a  v a2  s .co  m-->
  display: flex;
}

li {
  flex: 0 0 40px;
}

@media ( max-width : 1000px) {
  ul {
    flex-direction: row-reverse;
    justify-content: flex-end;
  }
}
</style>
</head>
<body>
  <ul>
    <li>1</li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
    <li>5</li>
    <li>6</li>
    <li>7</li>
    <li>8</li>
    <li>9</li>
    <li>10</li>
  </ul>
</body>
</html>

The code above is rendered as follows: