Span alignment with css

Asked

Viewed 842 times

1

I need to align the star icon ('material-icons') with the text ('span') and the menu icon ('overflow-menu'), all horizontal.

Can anyone help me? I have to do this without changing the html structure.

.container {
  left: 0;
  right: 0;
  margin: 10px auto 10px auto;
  width: 95%;
  border-radius: 4px;
  background: #FFFFFF;
}
.container table {
  width: 100%;
  margin: 0 auto;
}
.container .linha {
  border-top: 1px solid #D7D7D7;
}
.container-head {
  display: table;
  width: 100%;
  color: #FFFFFF;
  border-radius: 4px 4px 0 0;
  height: 65px;
  background: #000;
}
.container-head span {
  background: #000;
}
.container-head .material-icons {
  padding: 20px 0 20px 20px;
  width: 24px;
}
.container-head button {
  margin-top: 12px;
  margin-right: 20px;
  border: 0;
  width: 100px;
  height: 42px;
  cursor: pointer;
  border-radius: 4px;
  color: #FFFFFF;
  float: right;
}
.container-head button .material-icons {
  padding: 0;
  position: absolute;
  margin-top: -12px;
  margin-left: 32px;
}
.container-body {
  padding: 20px;
}
.container-body .notification {
  margin-left: -20px;
  margin-right: -20px;
}
.container-body .tab-content {
  margin-left: -15px;
  margin-right: -15px;
}
.container-body-scroll {
  overflow: auto;
  height: 319px;
  text-align: left;
}
.container-footer {
  border-top: 1px solid #D7D7D7;
  height: 45px;
  padding-left: 10px;
  padding-right: 10px;
}
.container-footer button .material-icons {
  font-size: 16px;
}
.container-footer button {
  margin-top: 7px;
  border: 0;
  padding: 7px;
  cursor: pointer;
  border-radius: 4px;
  color: #FFFFFF;
  float: right;
}
.container-footer .txt {
  float: left;
  margin-top: 12px;
}
<!-- Material Icons (Google) -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

<div class="container">

  <!-- Container Head -->
  <div class="container-head">
    <i class="material-icons text-yellow-2">grade</i>
    <span>TÍTULO CONTAINER</span>

    <!-- Over-Flow Menu -->
    <div class='overflow-menu'>
      <i class="material-icons">more_vert</i>

    </div>
  </div>
  <!-- Container Body -->
  <div class="container-body">
    TEXTO
  </div>
  <!-- Container Footer -->
  <div class="container-footer">
    <div class="txt">
      RODAPÉ
    </div>
  </div>
</div>

  • Have you tested .container-head > * {&#xA; display: inline-block;&#xA;}? or float: left;?

1 answer

1


.container {
  left: 0;
  right: 0;
  margin: 10px auto 10px auto;
  width: 95%;
  border-radius: 4px;
  background: #FFFFFF;
}
.container table {
  width: 100%;
  margin: 0 auto;
}
.container .linha {
  border-top: 1px solid #D7D7D7;
}
.container-head {
  display: table;
  width: 100%;
  color: #FFFFFF;
  border-radius: 4px 4px 0 0;
  height: 65px;
  background: #000;
  line-height: 65px;
}
.container-head span {
  display: inline-block;
  vertical-align: middle;
  padding: 0px 20px 0px 20px;
}
.container-head .material-icons {
  width: 24px;
  display: inline-block;
  vertical-align: middle;
  padding: 0px 0px 0px 20px;
}
.container-head .overflow-menu {
  float: right;
  vertical-align: middle;
}
.container-head .overflow-menu .material-icons {
  padding-right: 20px;
}
.container-head button {
  margin-top: 12px;
  margin-right: 20px;
  border: 0;
  width: 100px;
  height: 42px;
  cursor: pointer;
  border-radius: 4px;
  color: #FFFFFF;
  float: right;
}
.container-head button .material-icons {
  padding: 0;
  position: absolute;
  margin-top: -12px;
  margin-left: 32px;
}
.container-body {
  padding: 20px;
}
.container-body .notification {
  margin-left: -20px;
  margin-right: -20px;
}
.container-body .tab-content {
  margin-left: -15px;
  margin-right: -15px;
}
.container-body-scroll {
  overflow: auto;
  height: 319px;
  text-align: left;
}
.container-footer {
  border-top: 1px solid #D7D7D7;
  height: 45px;
  padding-left: 10px;
  padding-right: 10px;
}
.container-footer button .material-icons {
  font-size: 16px;
}
.container-footer button {
  margin-top: 7px;
  border: 0;
  padding: 7px;
  cursor: pointer;
  border-radius: 4px;
  color: #FFFFFF;
  float: right;
}
.container-footer .txt {
  float: left;
  margin-top: 12px;
}
<!-- Material Icons (Google) -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

<div class="container">

  <!-- Container Head -->
  <div class="container-head">
    <i class="material-icons text-yellow-2">grade</i>
    <span>TÍTULO CONTAINER</span>

    <!-- Over-Flow Menu -->
    <div class='overflow-menu'>
      <i class="material-icons">more_vert</i>
    </div>

  </div>
  <!-- Container Body -->
  <div class="container-body">
    TEXTO
  </div>
  <!-- Container Footer -->
  <div class="container-footer">
    <div class="txt">
      RODAPÉ
    </div>
  </div>
</div>

  • the 'overflow-menu' has to be at the end, the right, has like?

  • 1

    Fixed. Watch now.

  • OK there is only one thing, there are some 'container' that will not have the star icon, in this case the text is getting misaligned, have as you check?

  • If it has helped you mark the answer as correct, please. Be aware that I have answered more than you said in the question.

  • yes of course, I will mark, I was just waiting for you to answer me and help me with the last question. Could you help me?

  • I did. 27 minutes ago.

  • OK, thank you very much, I hadn’t seen

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.