0

As shown in the code snippet below i have created two buttons that are always the same width, but im unable to make a gap between them. Same goes for the mediaquery version (mobile) How can i do it?

.flex-container {
  display: flex;
  justify-content: center;   
  margin: 1em;
  
}

.flex-container .flex-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
 
}

.flex-item {
  height: 1.7rem;
  padding: 0 1.2rem;
  width: 100%;
 
}

.item1{
 margin-right:1vw; /*wont work*/
}


@media only screen and (max-width: 480px) {
.flex-container  .flex-container{
   display:flex;
   flex-direction: column; 
  }
}
<div class="flex-container">
  <div class="flex-container">
    <button class="flex-item item1">Button1</button>
    <button class="flex-item">Button2 really long with same width</button>
  </div>
</div>
mouchin777
  • 1,428
  • 1
  • 31
  • 59

1 Answers1

1

column-gap: 1vw; works as expected:

.flex-container {
  display: flex;
  justify-content: center;
  margin: 1em;
  column-gap: 1vw;
}

.flex-container .flex-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.flex-item {
  height: 1.7rem;
  padding: 0 1.2rem;
  width: 100%;
}

@media only screen and (max-width: 480px) {
  .flex-container .flex-container {
    display: flex;
    flex-direction: column;
  }
}
<div class="flex-container">
  <div class="flex-container">
    <button class="flex-item item1">Button1</button>
    <button class="flex-item">Button2 really long with same width</button>
  </div>
</div>
connexo
  • 53,704
  • 14
  • 91
  • 128