I made three things on the same line with divs and CSS float left and right. But the thing in the middle is not centered and it’s not wide enough. How do I make the middle thing centered?
Edit: Thankyou all for helping me. I appreciated
.box1 {
float: left;
}
.box2 {
float: left;
}
.box3 {
float: right;
}
<div class="box1">
<p>hello</p>
</div>
<div class="box2">
<table>
</table>
</div>
<div class="box3">
<p>Hello again</p>
</div>
3
Answers
Here’s one (very basic) solution; just make each box fill a fixed percentage of the page. Although I’d probably go with a flex box approach myself. Just another option…
You can use
display:flex
attribute fordesign
items side by side. And fortable
you can use tr td th elements . Additionally you i usedjustify-content:start-center-end
attributes Finally You should givewidth:auto
value to thebox
classesYou can do that with
display: flex;
andjustify-content: space-between;
in a div container.Maybe this can help you: