Quiero alinear el texto del lado derecho. Pero ese texto no tiene ninguna identificación o clase.

.list{list-style:none;}

.list li{padding:10px;border:1px solid black;margin-top:3px;}
.list li a{color:black;}
.list li a:before {
  content: "\f00c"; /* FontAwesome Unicode */
  font-family: FontAwesome;
  display: inline-block;
  margin-left: 1px; /* same as padding-left set on li */
  margin-right:10px;
}
<ul class="list">
<li class="incomplete"><a href="http://localhost/">First Lesson</a> - Not completed</li>
<li class="incomplete"><a href="http://localhost/">Second Lesson</a> - Not completed</li>
<li class="incomplete"><a href="http://localhost/">Third Lesson</a> - Not completed</li>
<li class="incomplete"><a href="http://localhost/">Fourth Lesson</a> - Not completed</li>
<li class="incomplete"><a href="http://localhost/">Fifth Lesson</a> - Not completed</li>
<li class="incomplete"><a href="http://localhost/">Sixth Lesson</a> - Not completed</li>
</ul>

Quiero alinear el texto Not completed al lado derecho.

2
Yus 14 jun. 2020 a las 18:29

3 respuestas

La mejor respuesta

Use flex para li y use justify-content:space-between;

violín para jugar.

.list {
  list-style: none;
}

.list li {
  padding: 10px;
  border: 1px solid black;
  margin-top: 3px;
  display: flex;
  justify-content: space-between;
}

.list li a {
  color: black;
}

.list li a:before {
  content: "\f00c";
  /* FontAwesome Unicode */
  font-family: FontAwesome;
  display: inline-block;
  margin-left: 1px;
  /* same as padding-left set on li */
  margin-right: 10px;
}
<ul class="list">
  <li class="incomplete"><a href="http://localhost/">First Lesson</a> - Not completed</li>
  <li class="incomplete"><a href="http://localhost/">Second Lesson</a> - Not completed</li>
  <li class="incomplete"><a href="http://localhost/">Third Lesson</a> - Not completed</li>
  <li class="incomplete"><a href="http://localhost/">Fourth Lesson</a> - Not completed</li>
  <li class="incomplete"><a href="http://localhost/">Fifth Lesson</a> - Not completed</li>
  <li class="incomplete"><a href="http://localhost/">Sixth Lesson</a> - Not completed</li>
</ul>
3
Manjuboyz 14 jun. 2020 a las 15:34

Simplemente agregue una propiedad text-align: right css al elemento padre ul y luego use la propiedad float: left css para cada elemento a de esta manera:

.list{list-style:none;text-align: right;}

.list li{padding:10px;border:1px solid black;margin-top:3px;}

.list li a{color:black;float: left;}

.list li a:before {
  content: "\f00c"; /* FontAwesome Unicode */
  font-family: FontAwesome;
  display: inline-block;
  margin-left: 1px; /* same as padding-left set on li */
  margin-right:10px;
}
<ul class="list">
<li class="incomplete"><a href="http://localhost/">First Lesson</a> - Not completed</li>
<li class="incomplete"><a href="http://localhost/">Second Lesson</a> - Not completed</li>
<li class="incomplete"><a href="http://localhost/">Third Lesson</a> - Not completed</li>
<li class="incomplete"><a href="http://localhost/">Fourth Lesson</a> - Not completed</li>
<li class="incomplete"><a href="http://localhost/">Fifth Lesson</a> - Not completed</li>
<li class="incomplete"><a href="http://localhost/">Sixth Lesson</a> - Not completed</li>
</ul>
2
AndrewL64 14 jun. 2020 a las 17:53
First wrap "Not completed" by span tag. Then add the style . I think this will solve your problem.

.list li a span {
   float: right;
}

<ul class="list">
   <li class="incomplete"><a href="http://localhost/">First Lesson</a> - <span>Not completed</span></li>
</ul>
0
Nihar Ranjan Das 14 jun. 2020 a las 15:38