cssbook icon indicating copy to clipboard operation
cssbook copied to clipboard

suggestion: use `box-sizing: border-box` for the previous/next button example

Open sumbach opened this issue 9 years ago • 0 comments

In Chapter 5, the example the places vertically-centered previous and next buttons to the sides of the content area was very helpful. But I did find this phrase slightly confusing:

The -15px negative margin (half the width) places the box neatly on top of the box.

While this is accurate, it seems to imply that the box would be centered over the edge of the parent. It's a little off-center because the element's borders are not included in the 30-pixel width. I think this could improve the example:

.previous, .next {
  position: absolute;
  box-sizing: border-box;
  width: 40px;
  height: 25px;
  top: 0;
  bottom: 0;
  margin: auto;
}
.previous {
  left: 0;
  margin-left: -20px;
}
.next {
  right: 0;
  margin-right: -20px;
}

sumbach avatar Feb 03 '16 13:02 sumbach