こんにちは私はこれらの4つの同様の機能を簡素化したいと思います。最終的にセレクタのみが変更されます。どうすればいいですか?多くのありとあらゆること!複数の代わりに単一の関数を使用するJQuery
$('.box.standard .title').css({
'position' : 'absolute',
'left' : '50%',
'top' : '50%',
'margin-left' : -$('.box.standard .title').outerWidth()/2,
'margin-top' : -$('.box.standard .title').outerHeight()/2
});
$('.box.large .title').css({
'position' : 'absolute',
'left' : '50%',
'top' : '50%',
'margin-left' : -$('.box.large .title').outerWidth()/2,
'margin-top' : -$('.box.large .title').outerHeight()/2
});
$('.box.wide .title').css({
'position' : 'absolute',
'left' : '50%',
'top' : '50%',
'margin-left' : -$('.box.wide .title').outerWidth()/2,
'margin-top' : -$('.box.wide .title').outerHeight()/2
});
ありがとう、それは完璧に動作します! – Titifrim