absolute居中
.garden_name{ position: absolute; /* left: 50%; top: 50%; */ /* 50%为自身尺寸的一半 */ /* transform: translate(-50%, -50%); */ left: 0; top: 0; right: 0; bottom: 0; margin: auto; font-weight: bold; border: 1px solid red; width: 50%; height: 50%; text-align: center; }