![](/img/trans.png)
[英]How to vertically and horizontally center two images inside a div on a responsive page
[英]how to horizontally center a responsive div?
嘗試將包含響應性Adsense代碼的div 居中 。
例如:
<div class="wrapper">
<div class="adsense">adsense code here</div>
</div>
如果我輸入廣告的確切尺寸,則可以將div居中。 因此728x90是我想要的最大值。 目前,我有一個img作為臨時位置,它工作正常。 問題是,如果我輸入確切的px,那么它將不會響應。
有什么想法嗎?
好的,這是我的實際代碼...
<section class="main-content">
<div class="top-banner">
<img src="img/ad_top.jpg">
</div>
</section>
(img作為記事本++的占位符)
.main-content {
float: left;
width: 75%;
}
.top-banner {
margin:0 auto;
}
這只是將img放置在左側而不是居中。
你在說什么? 水平居中以margin: 0 auto;
完成margin: 0 auto;
容器的大小無關緊要。
您如何看待?:
.wrapper{
width:100vw;
border:1px solid red;
}
.adsense{
border:1px solid black;
width:80%;
margin:0 auto;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.