所以我在一个名为 content-pic 的 div 中水平居中两个图像时遇到了问题。我已经尝试过如何在 div 中垂直居中图像和在此处如何在 div 中垂直居中图像的解决方案,这些解决方案似乎不适用于我的问题。我的问题是如何在标题下方的 div 内容中通过 css 水平居中图像?我是否有一个我丢失的属性,或者我只是要弄乱填充/边距,直到它们看起来正确?
html
<body>
<div id="wrapper">
<div id="header">
<div id="mast"><img src="http://i1256.photobucket.com/albums/ii488/terafanb/guildwars2/26.png" height="99" width="774=" /></div>
<div id="below-mast">
<!--Start of below mast -->
<img class="nav" src="http://i157.photobucket.com/albums/t60/Dragon_Aleph/fantasy_warrior_23022-800x600.jpg" height="297" width="226" border="0" alt="Crusader Army" />
<img class="Guy" src="http://i157.photobucket.com/albums/t60/Dragon_Aleph/fantasy_warrior_23022-800x600.jpg" height="297" width="549" border="0" alt="Crusader Army" />
</div>
<!--end of below mast -->
</div>
<!--end header -->
<div id="content">
<!--Start of content -->
<img class="content-pic" src="http://i157.photobucket.com/albums/t60/Dragon_Aleph/fantasy_warrior_23022-800x600.jpg" height="252" width="184" border="0" alt="Crusader Army" />
<img class="content-pic" src="http://i157.photobucket.com/albums/t60/Dragon_Aleph/fantasy_warrior_23022-800x600.jpg" height="252" width="184" border="0" alt="Crusader Army" />
</div>
<!--End of content -->
<div id="footer">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="whatIs1031.html">What is a 1031 Exchange?</a></li>
<li><a href="exchangeRequ.html">
1031 Exchange Requirements</a>
</li>
<li><a href="typesOfExchange.html">Types of Exchanges</a></li>
<li><a href="howToStart.html">How to get Started</a></li>
<li><a href="whyCLX.html">Why CLX?</a></li>
<li><a href="resources.html">Resources</a></li>
<li><a href="fAQs.html">FAQs</a></li>
<li><a href="fees.html">Fees</a></li>
<li><a href="contactUs.html">Contact Us</a></li>
</ul>
</div>
<!--end of footer -->
</div>
<!--End of Wrapper -->
CSS
body {
margin: 0;
padding: 0;
}
#wrapper {
margin: 0 auto; /* use shorthand */
width: 774px;
}
#content {
float: left;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
text-align: center;
background-color: green;
}
ul {
list-style: none;
margin: 20px auto;
width: 600px;
}
dd {
margin-left: 6em;
}
.nav{float: left;}
.Guy{width:500px;
margin-left: 30px;
}
.content-pic{}
.we-pay {
font-size: 13px
}
.note{
text-align:center;
}
.disclaimer {
font-size: 13px;
text-align: center;
font-weight: bold;
font-style: italic;
}
.FAQ{
font-size:14px;
}
.FAQ li{
margin:20px 0px 20px 0px;
}
.Question{
font-weight:bold;
}
#footer {
clear:both;
text-align:center;
margin-top:300px;/* The margin is so large becuase it is cleared and need to be larger much large than content */
}
#footer li {
display: inline;
border-left: 2px solid #000;
padding: 0 3px 0 3px;
}
#footer li:first-child {
border: none;
}
#footer a {
font-family: Helvetica, sans-serif;
color: #300000;
}
这是我在代码笔上的代码,为您提供方便http://codepen.io/Austin-Davis/full/fJLEn。