Html 将google maps iframe居中
嗨,我不是很熟悉CSS,但是我需要一个谷歌地图来集中在我的页面上,我当前的代码不能按我想要的方式工作 这是我的htmlHtml 将google maps iframe居中,html,css,positioning,center,Html,Css,Positioning,Center,嗨,我不是很熟悉CSS,但是我需要一个谷歌地图来集中在我的页面上,我当前的代码不能按我想要的方式工作 这是我的html <div class="maps"> <iframe src="https://www.google.com/maps/d/embed?mid=zZVPDX7DZETc.kFjAmXvee3Zc" width="512" height="384"></iframe> </div> 我做错了什么?我还试过使用marginright
<div class="maps">
<iframe src="https://www.google.com/maps/d/embed?mid=zZVPDX7DZETc.kFjAmXvee3Zc" width="512" height="384"></iframe>
</div>
我做错了什么?我还试过使用marginright/left:auto;那是行不通的 使用以下命令
.maps {
width: 512px;
display: block;
margin: 0 auto;
}
使用以下方法
.maps {
width: 512px;
display: block;
margin: 0 auto;
}
通常有两种方法居中元素,如果它是
display:block
,则可以margin right:auto;左边距:自动代码>只要设置了宽度
即可。如果是display:inline
,则可以在其父元素上使用text align:center
通常有两种居中元素的方法,如果是display:block
,则可以右边距:自动;左边距:自动代码>只要设置了宽度
即可。如果它是display:inline
,那么您可以在其父级上使用text align:center
,您也不需要添加div。您只需在其内部给它一个类即可
<iframe src="https://www.google.com/maps/d/embed?mid=zZVPDX7DZETc.kFjAmXvee3Zc" width="512" height="384" class="map"></iframe>
如果这对任何人都有帮助…您也不需要添加div。您只需在其中给它一个类即可
<iframe src="https://www.google.com/maps/d/embed?mid=zZVPDX7DZETc.kFjAmXvee3Zc" width="512" height="384" class="map"></iframe>
如果这对任何人都有帮助…如果iframe位于具有固定宽度的元素内,则谷歌默认使用iframe嵌入代码:
<div style="margin:0 auto;">
<iframe src="https://www.google.com/maps/embed?pb=YourMap" width="600" height="450" frameborder="0" style="border:0; margin:0 auto;" allowfullscreen></iframe>
</div>
如果iframe位于具有固定宽度的元素内,则谷歌默认使用iframe嵌入代码:
<div style="margin:0 auto;">
<iframe src="https://www.google.com/maps/embed?pb=YourMap" width="600" height="450" frameborder="0" style="border:0; margin:0 auto;" allowfullscreen></iframe>
</div>