1

I'm trying to duplicate a very basic layout where the logo is exactly in the center and two icons of different size are at the left and right of the header bar.

What I need is (1) but what I get is (2):

enter image description here

.showcase header {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 0px 0px;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
<section class="showcase">
  <header>
    <div class="toggle">toggle</div>
    <h2 class="logo">LOGO</h2>
    <div class="booknow">averyverylongbooknow</div>
  </header>
</section>
Youssouf Oumar
  • 29,373
  • 11
  • 46
  • 65
Vulkan
  • 1,004
  • 16
  • 44

3 Answers3

1

You could use CSS Grid along with Flexbox. What I did below is to give every column 1/3 of the parent's width, then position them as I want inside that given espace.

.showcase header {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  padding: 0 1rem;
  box-sizing: border-box;
}

.logo {
  display: flex;   
  justify-content: center; 
}

.booknow { 
  display: flex;   
  justify-content: flex-end; 
}
<section class="showcase">
  <header>
    <div class="toggle">toggle</div>
    <h2 class="logo">LOGO</h2>
    <div class="booknow">averyverylongbooknow</div>
  </header>
</section>
Youssouf Oumar
  • 29,373
  • 11
  • 46
  • 65
0

I'd try:

header > * {
  width: 33%;
  text-align: center;
}
EvgenyKolyakov
  • 3,310
  • 2
  • 21
  • 31
0

Please try this make you to Get a result justify-content: space-around;

showcase header {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  padding: 0px 0px;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-around;
}
Youssouf Oumar
  • 29,373
  • 11
  • 46
  • 65
  • I was just about to comment this too xD. I think this will solve his problem too. – Leo Ramadani Jun 17 '22 at 07:12
  • 1
    Except it doesn't output what he wanted as you can see here https://codepen.io/yousoumar/pen/JjpzevM. Please use the HTML he gave to make a runnable snippet. – Youssouf Oumar Jun 17 '22 at 07:25
  • Yes that only i will give you to solve – Rajiv Kumar Jun 17 '22 at 07:44
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 17 '22 at 16:03