View Single Post
Old 07-05-2025, 10:39 AM   #21
RbnJrg
Wizard
RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.RbnJrg ought to be getting tired of karma fortunes by now.
 
Posts: 1,834
Karma: 8700631
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
Quote:
Originally Posted by ElMiko View Post
@RbnJrg - So, I'm still struggling to see the difference between float and in-line block. They boy seem to make the element "float". Is it that the formal "float" will only work in terms of floating all the way right or all the way left, whereas inline-block can "float" relatively throughout a given element?
Maybe this can help you:

Click image for larger version

Name:	One1.jpg
Views:	35
Size:	32.1 KB
ID:	216737

Code:
  <h2>Example on inlined blocks</h2>

  <p><span class="col1">A label</span><span class="col2">The text asociated to the label on the left. As you can see this text does not surround the previous one</span></p>

  <h2>Example on floated blocks</h2>

  <p><span class="col3">A label</span><span class="col4">The text asociated to the label on the left. As you can see this text does surround the previous one</span></p>
Code:
.col1 {
  display: inline-block;
  width: 20%;
  vertical-align: top;
  background: lightgreen;
}

.col2 {
  display: inline-block;
  width: 80%;
  vertical-align: top;
  background: lightblue;
}

.col3 {
  float: left;
  padding-right: 4px;
  background: orange;
}

.col4 {
  background: khaki;
}
However, if in .col4 you add the properties:

Code:
  float: right;
  width: 80%;
apparently they have a similar appearance. BUT the solution with "display: inline-block" keeps the blocks together (they have the "page-break-inside: avoid" property implicit), and that doesn't happen when the blocks are floating.

Last edited by RbnJrg; 07-05-2025 at 10:45 AM.
RbnJrg is offline   Reply With Quote