Reputation: 14250
I am trying to text-align to center on a div with texts. The texts inside the div needs to be aligned to the left.
In my jsfiddle
html
<div class="parent">
<div class="texts">my text my text my text<br>my textmy text</div>
</div>
CSS
.parent {
text-align:center;
}
.texts{
//not sure what to do
}
I need to have texts div center inside the parent div but no indentations on two lines of texts. I can't really set the widths because they all needs to be responsive. How do I solve this? Thank you!
https://jsfiddle.net/bh4pu001/
Upvotes: 2
Views: 51
Reputation: 57
Please Use Following code
.parent {
float:left;
}
.texts{
float:left;
text-align:center;
}
.parent {
float:left;
}
.texts{
float:left;
text-align:center;
}
<div class="parent">
<div class="texts">my text my text my text<br>my textmy text</div>
</div>
Upvotes: 0
Reputation: 1352
set display: inline-block;
.texts{
text-align: left;
display: inline-block;
}
Upvotes: 0
Reputation: 20199
Use
.parent {
text-align:center;
}
.texts{
display: inline-block;
text-align: left;
}
<div class="parent">
<div class="texts">my text my text my text<br>my textmy text</div>
</div>
Upvotes: 2