我想将中心设置为.user-menu位置,但下面的代码不起作用.我怎么解决这个问题?
<body> <div class="user-menu"> <div class="menu-items"> <div class="bought-tickects centered hover-effect"></div> <label>تاریخچه خرید</label> </div> <div class="menu-items"> <div class="profile centered hover-effect"></div> <label>حساب کاربری</label> </div> <div class=""></div> </div> <div class="clear"></div> <div class="container-of-selected"> </div> </body>
CSS
* { margin: 0px; padding: 0px; font-family: Tahoma; } .centered { margin-left: auto; margin-right: auto; } .menu-items { float: left; height: 90px; margin-left: 10px; margin-right: 10px; } .profile { width: 72px; height: 72px; padding-left: 10px; padding-right: 10px; background-repeat: no-repeat; background-position: center; background-image: url('Images/folder-contacts-icon.png'); border-radius: 5px; } .bought-tickects { width: 72px; height: 72px; padding-left: 10px; padding-right: 10px; background-repeat: no-repeat; background-position: center; background-image: url('Images/tickets-icon.png'); border-radius: 5px; } .clear { clear:both; } .user-menu { margin-left:auto; margin-right:auto; }