我正在尝试将三个 div 居中在另一个 div 中。我似乎无法让它工作。我的网站是响应式的,也许这与它有关?这是我到目前为止的代码和CSS,非常感谢任何帮助!
我试图让所有三个 div.hp-highlight
居中.home-highlights
:
<div id="home-highlights" class="clearfix">
<div class="heading">
<h2><a href="http://kompufast.com/?page_id=1909" title="What We Do"><span>What We Do</span></a></h2>
</div>
<!-- /heading -->
<div class="hp-highlight ">
<img src="http://kompufast.com/wp-content/uploads/2012/06/kompufast_sales1.jpg" title="Sales" class="hp-highlight-img" />
<h3><a href="http://kompufast.com/?services=safe-computing" title="Sales" target="_self">Sales</a></h3>
<p>KompuFAST+ is the right company to help you address your need for all kind of consumer technology products.</p>
</div>
<!-- /hp-highlight -->
<div class="hp-highlight ">
<img src="http://kompufast.com/wp-content/uploads/2012/02/kompufast_order1.jpg" title="Order" class="hp-highlight-img" />
<h3><a href="http://kompufast.com/?services=social-media" title="Order" target="_self">Order</a></h3>
<p>KompuFAST-Order facilitates the ordering of products, without a fee for special order.</p>
</div>
<!-- /hp-highlight -->
<div class="hp-highlight highlight-third ">
<img src="http://kompufast.com/wp-content/uploads/2012/02/kompufast_fix1.jpg" title="Fix" class="hp-highlight-img" />
<h3><a href="http://kompufast.com/?services=shared-hosting " title="Fix" target="_self">Fix</a></h3>
<p>KompuFAST+ has a team of dedicated repair technicians ready to diagnose your computer for all sorts of problems.</p>
</div>
这是我一直在尝试的 CSS:
.home-highlights {
margin-right:auto;
margin-left:auto;
width: 100%;
}
.hp-highlight {
width: 280px;
}