Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

text-align right in small width div

Tags:

css

text-align

I'm trying to align text to the right in a small area. It becomes left align when the container is small. Is there anyway to force it right align?

div 
{ float: right;
width: 100px;
height: 50px;
text-align: right;
border: thin solid black;
}

https://jsfiddle.net/a362zr54/

like image 542
echo Avatar asked Feb 08 '23 09:02

echo


1 Answers

If you add direction: rtl; it will do that

div { 
  float: right;
  width: 100px;
  height: 50px;
  text-align: right;
  border: thin solid black;
  direction: rtl;
}
<div>
1testtesttesttesttesttesttesttesttest2
</div>
like image 132
Asons Avatar answered Feb 13 '23 06:02

Asons