Answers for "absolute center horizontal"

9

absolute position center

position: absolute;
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
text-align: center;
Posted by: Guest on May-24-2020
1

absolute center position

// center horizontal 

.product-item-div {
	position: relative;
}

.sold_out {
	position: absolute;
	padding: 6px;
	top: 180px;
	left: 50%;
	transform: translate(-50%, -50%);
	background-color: @wishlist-grey;
	color: white;
	border-radius: 5px;
}




// center vertical 

.product-item-div {
	position: relative;
}

.sold_out {
	position: absolute;
	padding: 6px;
	top: 50%;	/* fix here */
	left: 50%;
	transform: translate(-50%, -50%);
	background-color: @wishlist-grey;
	color: white;
	border-radius: 5px;
}
Posted by: Guest on February-23-2021
0

center absolute element

.child {
    position: absolute;
    top: 50%;  /* position the top  edge of the element at the middle of the parent */
    left: 50%; /* position the left edge of the element at the middle of the parent */

    transform: translate(-50%, -50%); /* This is a shorthand of
                                         translateX(-50%) and translateY(-50%) */
}
Posted by: Guest on September-15-2021

Code answers related to "absolute center horizontal"

Browse Popular Code Answers by Language