I have an inner div with three children; a button, some text and a button group.
I am using flex
to center everything, but the problem is that the text is not actually centered with respect to the containing element. It is instead centering the text in between the near borders of the button and button group.
The text is not centered within the yellow box. I want the text to be centered in the yellow box.
Is there some way to say "measure from the edges of the outer element and ignore the inner edges of siblings"?
.outer-box {
width: 100%;
display: flex;
justify-content: center;
}
.inner-box {
width: 500px;
height: 60px;
background-color: yellow;
display: flex;
justify-content: space-between;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
</br>
<div class="outer-box">
<div class="inner-box">
<button class="btn">My Button</button>
<span>My text here</span>
<div class="btn-group">
<button class="btn">My Button1</button>
<button class="btn">My Button2</button>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</body>
</html>