【问题标题】:Center Google Form with CSS使用 CSS 居中 Google 表单
【发布时间】:2015-01-23 12:42:47
【问题描述】:
我在我的网站上嵌入了一个 google 表单,该表单包含在一个 div 中。我尝试使用 CSS 将其居中,但它不起作用。有没有办法完成这个任务?
我的代码:
#googleForm {
margin-left: auto;
margin-right: auto;
}
<div id="googleForm">
<iframe src="https://docs.google.com/forms....></iframe>
</div>
【问题讨论】:
标签:
html
css
google-forms
【解决方案1】:
您可以将text-align: center 添加到ID 为googleForm 的元素。您也可以安全地删除margin-left 和margin-right:
#googleForm {
/*margin-left: auto;/*
/*margin-right: auto;*/
text-align: center;
}
<div id="googleForm">
<iframe src="https://docs.google.com/forms....></iframe>
</div>
如果你想使用margin: 0 auto你必须设置元素的宽度:
#googleForm {
width: 304px;
margin: 0 auto;
}
<div id="googleForm">
<iframe src="https://docs.google.com/forms....></iframe>
</div>