Reputation: 722
My problem is as simple as stupid. I have a <div>
that holds 2 <p>
on it, where the 2nd <p>
has a float: right;
value on it.
How can I center align the first <p>
with the 2nd <p>
on it side-by-side?
How it Looks Like now:
.bubble_text {
display: inline-block;
padding: 1vw 3vw;
background-color: rgba(0, 0, 0, 0.1);
border-radius: 20vw;
text-align: center;
}
<div class="container">
<p class="bubble_text">Center me Please</p>
<p style="float: right;">✖</p>
</div>
Upvotes: 0
Views: 63
Reputation: 1214
Try this
HTML
<div class = "container">
<p class = "bubble_text">Center me Please</p>
<p style = "float: right;">✖</p>
</div>
CSS
container{
text-align:center;
}
.bubble_text {
display: inline-block;
padding: 1vw 3vw;
background-color: rgba(0, 0, 0, 0.1);
border-radius: 20vw;
vertical-align:middle;
margin:0 auto;
}
Demo https://jsfiddle.net/jr9s7ayf/
Upvotes: 0
Reputation: 14860
Just add text-align:center
to the container element and you're good to go
.container{
text-align:center;
}
.bubble_text {
display: inline-block;
padding: 1vw 3vw;
background-color: rgba(0, 0, 0, 0.1);
border-radius: 20vw;
text-align: center;
margin:0 auto;
}
<div class = "container">
<p class = "bubble_text">Center me Please</p>
<p style = "float: right;">✖</p>
</div>
Upvotes: 1