Chetan Warke
Chetan Warke

Reputation: 11

inline block and text align are not working in same div

    <div style="text-align:right;border-radius:6px;padding:4px;border-color:grey;background-color:#D8D8D8;">text</div>

I want to align text to right as well want to use inline-block.But when i used inline-block it get shifted to start of div i.e. to left side

Upvotes: 1

Views: 81

Answers (1)

A. Meshu
A. Meshu

Reputation: 4148

If I understand right you are trying to put the div on the right side and that it's width will be the text width. You can achieve that with parent element like that:

<div style="text-align: right;">
  <div style="display: inline-block; text-align:right;border-radius:6px;padding:4px;border-color:grey;background-color:#D8D8D8;">text</div>
</div>

Or with float (and clear) like that: (If you doing it you don't need the display inline-block)

<div style="float: right; clear: left; text-align:right;border-radius:6px;padding:4px;border-color:grey;background-color:#D8D8D8;">text</div>

Hope it helps.

Upvotes: 1

Related Questions