jQuery center element to viewport using center plugin

前端 未结 2 1526
孤独总比滥情好
孤独总比滥情好 2021-01-22 21:04

I am currently using the jQuery center plugin to center my div element and so far it works to an extend where it does center it to the containing parent container. What I want

2条回答
  •  轮回少年
    2021-01-22 21:28

    No plug-in is needed. This does the trick:

    $('#yourElement').css('display', 'inline-block').wrap('
    ');

    Live demo: http://jsfiddle.net/simevidas/EnrLn/1/


    Same thing, but without the TABLE element. I use DIV's with display:table and display:table-cell instead:

    Live demo: http://jsfiddle.net/simevidas/EnrLn/2/

提交回复
热议问题