Internal elements overlapping <Section>

Asked

Viewed 174 times

0

The tag <b> superimposes the tag <section> see example when using padding: inserir a descrição da imagem aqui

Note in the image above that the light gray bar refers to section gets smaller height than the tag b. That is, the internal tag overlaps.

Also when I resize the browser to tag b overlap itself, without giving due spacing. See in the example below:

inserir a descrição da imagem aqui

HTML

<section class="compartilhar">
<span>Compartilhar:</span>
<span>Compartilhar:</span>
<span>Compartilhar:</span>
<span>Compartilhar:</span>
<span>Compartilhar:</span>
<span>Compartilhar:</span>
</section>

CSS

section.compartilhar{
  width: 100%;
  max-width: 1200px;
  margin: auto;
  padding: 10px;
  box-sizing: border-box;
  background-color: #ccc;
}

section.compartilhar span{
  background-color: #333;
  padding: 15px;
  box-sizing: border-box
  font-size: 18px;
}
  • Gladison, the HTML <b> tag is meant to make the elements bold. Worry about never adding other styles to tag’s that are already set for a purpose, create a new class and assign these styles, this improves the interpretation for us and especially for you.

  • @I made the change. Thanks for the tip.

1 answer

2


As already said, the tag b, is intended for text formatting and must be handled by means of a container, for example...

section.compartilhar{
  width: 100%;
  max-width: 1200px;
  margin: auto;
  padding: 10px;
  box-sizing: border-box;
  background-color: #ccc;
  display: flex;
  height: 100%;
  flex-wrap: wrap;
}

section.compartilhar div{
  background-color: #333;
  padding: 15px;
  //box-sizing: border-box
  font-size: 18px;
}
<section class="compartilhar">
<div><b>Compartilhar:</b></div>
<div><b>Compartilhar:</b></div>
<div><b>Compartilhar:</b></div>
<div><b>Compartilhar:</b></div>
<div><b>Compartilhar:</b></div>
<div><b>Compartilhar:</b></div>
</section>

  • You posted the answer two seconds before me! Hahaha, to complement: If you want a spacing between them when there is the line break add margin-bottom: 5px; (optional value).

  • kkkk, normal happens to me always

Browser other questions tagged

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