如何使用CSS <div>在另一个内部水平居中<div>?
<div id="outer">
<div id="inner">Foo foo</div>
</div>
Run Code Online (Sandbox Code Playgroud) 大家好,我希望你做得很好.我正在使用Isotope,下面你可以看到我写的JavaScript.li如果它们是Isotope元素,我发现不可能将元素集中在一起.要通过居中查看我的意思,请参阅下面的图片.我已经设法将整个同位素集中到屏幕上,但我需要将元素集中在一起,而不是只浮动到左侧.
让我们从我的脚本代码开始:
<script>
$(document).ready(function(e) {
$(".ullist li").addClass('element-item');
});
</script>
<script>
$(document).ready(function(e) {
// external js: isotope.pkgd.js
// init Isotope
var $grid = $('.grid').isotope({
itemSelector: '.element-item',
//layoutMode: 'fitRows',
});
//$('.grid').isotope({ layoutMode : 'fitRows' });
// filter functions
var filterFns = {
// show if number is greater than 50
numberGreaterThan50: function() {
var number = $(this).find('.number').text();
return parseInt( number, 10 ) > 50;
},
// show if name ends with -ium
ium: function() {
var name = $(this).find('.name').text();
return …Run Code Online (Sandbox Code Playgroud)