Now there are two ways to know
Method One: Mainly applicable to the case where the element is not set height.
Directly on the code
Html:
1 <Divclass= "Nav-content">2 <ulNg-click= "Navitem ($event)"Ng-model= "Navtype">3 <LiID= "Nav_msglist">4 <ahref="#/">Message list</a>5 </Li>6 <LiID= "Mislist">7 <ahref="#/">Notification list</a>8 </Li>9 <Li>Ten <ahref="#/">Message list</a> One </Li> A <Li> - <ahref="#/">Message list</a> - </Li> the <LiID= "Userset"> - <ahref= "#/userset">Account Settings</a> - </Li> - </ul> + </Div>
Css:
1 . nav-content Li a {color: #6f6f6f; position: absolute; -webkit-transform: translatey ( -50%); Top: 50%; Display: block;}
Method Two: Applies to the case where the height of the element is known.
Html:
1 <Divclass= "Msg-operation">2 <Divclass= "Optico"><imgsrc= "Images/collect-ico.png" /></Div>3 <Divclass= "Optico"><imgsrc= "Images/collect-ico.png" /></Div>4 <DivClas= "Optico"><imgsrc= "Images/collect-ico.png" /></Div>5 </Div>
Css:
1 . optico{width:30%;d isplay:inline-block;position:relative;text-align:right;} 2 . Optico img{height:20px;width:20px;position:absolute;top:50%;margin-top: -10px;left:50%;margin-left: 10px;}
Of course, in the case of the left and right margin without setting margin, Div Center also has a method, that is, margin:0 auto;