2

Hie everyone,

I have this HTML structure I can't change :

<div>
  <ul>
    <li>1</li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
    <li>...</li>
  </ul>
  <a href="#">more</a>
</div>

The idea is to have the link right after the last "li" without using javascript.

Here is what i want to do :

inline blocks

And here is the starter kit with Codepen.

morkro
  • 4,336
  • 5
  • 25
  • 35
adoveil
  • 57
  • 5

3 Answers3

0

You could use css attribute :last-child to change style of the last square.

By the way, pay attention to the compatibility.

Here a simply demonstration.

ul li {
    background-color: red;
}

ul li:last-child {
    background-color: green;
}

Your Codepen updated.

Community
  • 1
  • 1
Luca Davanzo
  • 21,000
  • 15
  • 120
  • 146
0

It working ok

  <!DOCTYPE html >
<html >
<head>

<style>
ul li
{
    float:left;
    display:inline-block;
    width:40px;
    background-color:#FFC0CB;
    margin-right:5px;
    margin-bottom:5px;
    height:40px;
}
a
{
        float:left;
    display:inline-block;
    background-color:#800080;
    height:40px;
    color:white;
    width:40px;
    vertical-align:middle;
}
div ul
{
    width:120px;
}
</style>
</head>


<body>
<div>
  <ul>
    <li>1</li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
    <li>...</li>
  </ul>
  <a href="#">more</a>
</div>
</body>
</html>

Hope this help!

tuan huynh
  • 727
  • 5
  • 13
0
<div>
  <ul>
    <li>1</li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
    <li>5</li>
    <li>1</li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
    <li>5</li>
    <li>1</li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
    <li>5</li>
    <li>1</li>
    <li>2</li>
    <li>3</li>
    <li>4</li>
    <a href="#">more</a>
  </ul>
</div>

just remove the < L I > and the < / L I > before the < a >

Dany Minassian
  • 189
  • 4
  • 13