Centering a css dropdown menu

前端 未结 2 1281
萌比男神i
萌比男神i 2021-01-16 09:21

I\'m trying to center my css dropdown menu, but I can\'t seen to get it to work! I\'ve tried adding text-align: center and margin-left: auto; margin-right: auto, but all tha

2条回答
  •  醉梦人生
    2021-01-16 09:52

    Since you are using float, the only way to center it is to apply a width to the containing element and use margin-left: auto; margin-right: auto. There is no way to do this will retaining the flexible width.

    An alternative to float would be display:inline-block; These can be centered using text-align:center, but you'll have to rework the css.

提交回复
热议问题