View Single Post
Old 01-24-2025, 04:45 PM   #7
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 79,796
Karma: 146391129
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by nabsltd View Post
You can't truly center anything without using more than just margins, and you don't need to touch margins to center something...text-align: center; centers the content.

OTOH, you can use the following to "center" an image without centering text:
Code:
.image-box {
text-align: left;
margin-left: 20%;
margin-right: 20%;
}

.image-fill {
width: 100%;
}

<p class="image-box"><img src="some-image.png" class="image-fill"><br />
An un-centered caption.
</p>
There is one thing you can center with margins. This leaves a 20% 2px line centered.

Code:
hr {
  margin-top: 0.9em;
  margin-right: 40%;
  margin-bottom: 0.9em;
  margin-left: 40%;
  border-top: 2px solid;
}
JSWolf is offline   Reply With Quote