我想要做的是让一个图像居中,然后另一个图像与它内联并向左对齐。我试过搜索,但没有找到任何合适的方法。任何建议将不胜感激。
HTML
<div class="container">
<header>
<div>
<a href="index.html">
<img src="left.png" border="0" width="174" height="350" />
<img class="center" src="center.png" border="0" width="700" height="350" />
</a>
</div>
CSS
html
{
min-height:100%;
}
body
{
background-color: #9CF;
background-repeat: no-repeat;
}
body,td,th
{
font-size: large;
margin: 3% 5% 3% 5%;
}
.container
{
background-color: rgba(0,0,0,0.4);
padding: 6px;
}
.linkbg
{
background-color: #000000;
color: #FFF;
text-align:center;
}
.dashboard
{
text-align:right;
}
ul
{
background-color: #0099CC;
width:100%;
text-align:center;
list-style-type:none;
margin:0;
padding:0;
padding-top:6px;
padding-bottom:6px;
opacity:0.7;
}
li
{
display:inline;
}
.nava:link,.nava:visited
{
font-weight:bold;
color:black;
background-color:##0099CC;
text-align:center;
padding:6px;
text-decoration:none;
text-transform:uppercase;
}
.nava:hover,.nava:active
{
background-color: #00FFFF;
}
img
{
max-width: 100%;
height: auto;
width: auto\9;
}
.center
{
display:inline-block;
margin-left:auto;
margin-right:auto;
}
最佳答案
你可以尝试使用下面给定的技巧
<img style="margin:0px auto;display:block" src="Image URL Here"/>
如需完整评论,您可以查看以下链接 http://bloggingfear.blogspot.in/2012/11/how-to-center-image-using-html-5-code.html
关于html - 左对齐,并在容器内居中放置内联图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17094283/