我遇到了一个真正的问题,我确信这只是因为我没有长时间编码,很容易忽略简单的错误。我试图中心一个地址,并尝试包含在一个div,或只是格式化它自己,但我不能得到它的中心。请注意,我希望地址保持固定在屏幕上,所以滚动时它不会移动。这是我的代码(我知道每个人都讨厌人们粘贴大段代码,但我还没有学会如何链接我的jsfiddle页面)
<link rel="stylesheet" href="stylesheet for real index.css">
</style>
<head>
<title>Test of notepad ++</title>
</head>
<body>
<div style="text-align: center;height: 100%;background: #4FD5D6;">
<iframe src="index.html" scroll="no">Your browser doesn't support iFrames.</iframe>
</div>
<div class="center">
<address>
Made by <em><b>Dantoon e</b></em><br>So look out
</address>
</div>
</body>
和css
body {
font-family: Nobile;
background-color: #4FD5D6;
display: empty-cells; }
iframe {
display: block !important;
width: 1200px;
height: 1200px;
margin-top: -20px;
margin-right: auto;
margin-left: auto;
margin-bottom: -1000px;
box-shadow: 10px 10px 10px;
position: relative;
z-index: 0; }
.center {
border-top: thick dotted;
border-bottom: thick dotted;
background-color: black;
color: white;
position: fixed;
bottom: 5px;
width: 1204px;
text-align: center;
margin-left: auto;
margin-right: auto;
margin-bottom:5px;
display: inline;
margin-top: 0px;
z-index: 1; }
我只包括整个页面,因为我不知道是某个地方的疏忽可能会影响地址。谢谢预支!
你错过了一个开始的html标签和正文是在接近,加上有一个随机/样式:)
<html>
<head>
<link rel="stylesheet" href="stylesheet for real index.css" />
<title>Test of notepad ++</title>
<head>
<body>
<div style="text-align: center;height: 100%;background: #4FD5D6;">
<iframe src="index.html" scroll="no">Your browser doesn't support iFrames.</iframe>
</div>
<div class="center">
<address>
Made by <em><b>Dantoon e</b></em><br>So look out
</address>
</div>
</body>
</html>
与CSS: .center {
display: block;
border-top: thick dotted;
border-bottom: thick dotted;
background-color: black;
color: white;
position: fixed;
bottom: 5px;
width: 100%;
text-align: center;
}
这是一个可以工作的小提琴(br也需要一个尾斜杠)。另外,我不会把东西固定到1200像素-使用100%http://jsfiddle.net/QcSt9/1/
你需要做的是对这个做一些改变:
添加一个Container/Parentdiv,它将包含iframe的子div和中心类div:
<div class="container">
<iframe></iframe>
<div class="center">
<address>blah</address>
</div>
</div>
容器将有一个相对于....的类位置然后你可以根据你给iframe的容器宽度(1200px)将发送器类设置在底部居中
小提琴
另外,不确定你是否注意到,但是你的样式表链接在头部之外,你有一个无用的样式更接近和使用内联样式(没有错,但不推荐ether)
希望这对你有帮助