Home > Blockchain >  How to make icons and text in one line with inline-grid?
How to make icons and text in one line with inline-grid?

Time:09-16

I am trying to create contact field, but icon and text must be in one line. This is how it looks now:

enter image description here

.code-block {
  display: inline-grid;
  background-color: #232323;
  border-radius: 5px;
  padding: 5px;
  margin-bottom: 7px;
}

.code-block code {
  color: #008a00;
}

.code-block .icons {
  display: inline-block;
  vertical-align: top;
  width: 14px;
  height: 14px
}
<div class="code-block">
  <code>Discord: ...#6177</code>
  <img class="icons" src="https://via.placeholder.com/40" alt="Discord" width="10" height="10">
</div>

So, how can I make it in one line?

CodePudding user response:

I believe what you want is to update your scss the following rules to the .code-block:

grid-template-columns: max-content max-content;
align-items: center;
grid-gap: 4px;

so all the rules would look like:

.code-block {
  display: inline-grid;
  grid-template-columns: max-content max-content;
  align-items: center;
  grid-gap: 4px;
  background-color: #232323;
  border-radius: 5px;
  padding: 5px;
  margin-bottom: 7px;
}

.code-block code {
  color: #008a00;
}

.code-block .icons {
  display: inline-block;
  vertical-align: top;
  width: 14px;
  height: 14px
}
<div class="code-block">
  <code>Discord: ...#6177</code>
  <img class="icons" src="https://via.placeholder.com/40" alt="Discord" width="10" height="10">
</div>

  • Related