我尝试在我的CSS这样的属性,如文本对齐:中心,但它不工作。然后我尝试将左边距和右边距设置为自动,但它不起作用。我还能如何集中网页的所有信息?下面的代码:如何将网页正文与中心对齐?
<!DOCTYPE html>
<html>
<head>
<meta name="author" content="Yevhenii Zhdan">
<style type="text/css">
body {
padding: 20px;
}
h1, h2 {
font-weight: normal;
color: #0088dd;
margin: 0px;
text-align: center;
}
h1 {
background-image: url("images/bob.gif");
background-repeat: no-repeat;
text-indent: -9999px;
padding-bottom: 3%;
}
h2 {
padding: 10px;
width: 12em;
font-family: "Gill Sans", Arial, sans-serif;
font-size: 90%;
text-transform: uppercase;
letter-spacing: 0.2em;
border: 2px solid #0088dd;
border-right: none;
border-bottom: none;
}
</style>
</head>
<body>
<h1>YZhdan</h1>
<h2><b>How to find me:</b></h2>
<br />
<iframe
width="450"
height="350"
src="https://www.google.com.ua/maps?q=...&output=embed">
</iframe>
<p><b>© Yevhenii Zhdan</b></p>
</body>
</html>
body {
padding: 20px;
}
h1,
h2 {
font-weight: normal;
color: #0088dd;
margin: 0px;
text-align: center;
}
h1 {
background-image: url("images/bob.gif");
background-repeat: no-repeat;
text-indent: -9999px;
padding-bottom: 3%;
}
h2 {
padding: 10px;
width: 12em;
font-family: "Gill Sans", Arial, sans-serif;
font-size: 90%;
text-transform: uppercase;
letter-spacing: 0.2em;
border: 2px solid #0088dd;
border-right: none;
border-bottom: none;
}
<h1>YZhdan</h1>
<h2><b>How to find me:</b></h2>
<br />
<iframe width="450" height="350" src="https://www.google.com.ua/maps?q=...&output=embed">
</iframe>
<p><b>© Yevhenii Zhdan</b>
</p>
这将围绕75%的宽度容器里面的内容,但他们不会在这里面的容器,我认为居中是他想。 – Malcom
是的,文本不会居中,这只是在页面上给一个居中的容器。我认为那是他所问的,但我可能是错的。另请注意,宽度的75%只是一个任意值,它可以是任何宽度,但需要为宽度设置一些值。 –
嗯,这解决了他的问题,所以他可能只是寻找一个容器,而不是每个元素居中。 “我怎么能中心我的网页的所有信息”让我错了。 – Malcom