.center {
display: block;
margin-left: auto;
margin-right: auto;
}
img {
display: block;
margin: 0 auto;
}
<img src="myImg.png" class="center">
.center {
display: block;
margin-left: auto;
margin-right: auto;
width: 50%;
}
.centerImg {
display: block;
margin: 0 auto;
}
img {
display: block;
width: 60%; /* Or 600px instead of percentager value */
margin-left: auto;
margin-right: auto;
}
/* This method uses the margin property,
its typically used to center large images.
In this example the browser reads the image as a block element
(not an inline element) thus allowing the CSS margin property to work.
URL = https://blog.hubspot.com/website/center-an-image-in-html */
img {
display:block;
margin-left:auto;
margin-right:auto;
}
.someclass {
display: block;
margin-left: auto;
margin-right: auto;
}
<style type="text/css">
.centerImage
{
text-align:center;
display:block;
}
</style>
.classNameOfImage {
display: block;
margin-left: auto;
margin-right: auto;
}
body {
background-position: center;
}
Background-position:center;
Background-size:cover;
Background
-releat:no-repeat;