I'm attempting to design a navigation bar with a hamburger icon on the left and another icon centered. How can I achieve this while maintaining responsiveness?
- My initial attempt using mx-auto (margin-left margin-right: auto) didn't work as expected because the inline block on the left pushed the centered icon to the left.
- I also experimented with making the navbar d-flex and adding justify-content-center, but it had no effect...
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<div class="pos-f-t">
<nav id="navbar" class="navbar navbar-expand-sm fixed-top navbar-dark bg-dark d-flex flex-row">
<button class="navbar-toggler d-flex justify-content-start" type="button">
<span class="navbar-toggler-icon"></span>
</button>
<img src="https://picsum.photos/20" alt="apple icon" class="d-flex justify-content-center mx-auto" id="icon">
</nav>
</div>
Expected outcome: - The hamburger icon remains on the left, while the apple icon is centered.
Actual result: - The apple icon is slightly displaced right by the hamburger icon, - or there is no change at all, with the icon still positioned on the right side.