我已尝试一切方法将图像放在 @media only 屏幕和(最大宽度:480px)的页面上居中,但是没有任何效果。
代码如下:
前端
<figure class="img1 embed">
<img src="Images/testimonial-2.jpg" alt=""/>
</figure>
CSS
/*** Base Caption Styles ***/
figure.embed,
figure.embed-top,
figure.overlay,
figure.embed-over {
display: inline-block;
vertical-align: top;
position: relative;
margin: 0.5em;
font-size: 0.8em;
background: white;
overflow: hidden;
float: right;
}
figure.embed img,
figure.embed-top img,
figure.overlay img,
figure.embed-over img {
width: 100%;
display: block;
}
figure.embed figcaption,
figure.embed-top figcaption,
figure.overlay figcaption,
figure.embed-over figcaption {
width: 100%;
padding: 0.5em;
/* neutral theme */
color: rgba(50,50,50,1.0);
background: rgba(200,200,200,0.825);
}
谁能告诉我我需要对此代码执行什么操作才能使图像居中?我尝试过显示:块; margin: 0 auto 和 margin-left: auto; margin-right:自动,但无济于事。
任何帮助将非常感激!