HTML – 使用CSS中心Google表单

我在我的网站上嵌入了一个google表单,它包含在div中.我尝试用CSS中心,但它不起作用.有没有办法完成这项任务?

我的代码

#googleForm {
	margin-left: auto;
	margin-right: auto;
}
<div id="googleForm">	
  <iframe src="https://docs.google.com/forms....></iframe>
</div>

解决方法

您可以使用id googleForm将text-align:center添加到元素.您还可以安全地删除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>

相关文章

vue阻止冒泡事件 阻止点击事件的执行 &lt;div @click=&a...
尝试过使用网友说的API接口获取 找到的都是失效了 暂时就使用...
后台我拿的数据是这样的格式: [ {id:1 , parentId: 0, name:...
JAVA下载文件防重复点击,防止多次下载请求,Cookie方式快速简...
Mip是什么意思以及作用有哪些