在html中动态插入div到margin-top为-1em的h1标签前面
我正在尝试向现有文档插入逻辑页码。在下面的 xhtml 代码片段中,这是 .pagerule-cls div。我发现一个文档,这不能很好地工作,因为页面上第一个元素的影响 CSS 的 margin-top 为 -1em。我的页码插入最终位于原始文档的 h1 文本的中心。我可以做些什么来确保 h1 标题“Introduction”出现在我使用适当的 pagerule-cls css 插入页码之后?
顺便说一句,body元素上的样式也是我插入改变左右边距的。
安迪
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8"/>
<style>
.calibre14 {
display: block;
font-size: 1.5em;
font-weight: bold;
margin-bottom: 0.67em;
margin-left: 0;
margin-right: 0;
margin-top: -1em;
text-align: center
}
.calibre4 {
display: block;
margin-bottom: 0;
margin-left: 1.25em;
margin-right: 0;
margin-top: 0;
text-align: justify
}
.pagerule-cls {
text-align: center;
font: 13px Arial, Helvetica, sans-serif;
}
</style>
</head>
<body style='margin-left:100px;margin-right:10px;min-width:400px;max-width:800px;'><a name='stagpage6' id='stagpage6'/><div class='pagerule-cls'>7</div>
<div><blockquote class="calibre4"><span>
<h1 class="calibre14"><span><span class="bold"><a></a>INTRODUCTION</span></span></h1>
<div></div></span></blockquote></div>
</body>
</html>
I have existing documents that I'm trying to insert logical page numbers into. In the xhtml snippet below, this is the .pagerule-cls div. I found a document that this doesn't work well with because the affecting css for the first element on the page has a margin-top of -1em. My page number insertion ends up in the center of the h1 text of the orginal document. Is there anything I can do to make sure the h1 heading "Introduction" comes after my page number insertion with appropriate pagerule-cls css?
By the way, the style on the body element is also my insertion to change the left and right margins.
Andy
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8"/>
<style>
.calibre14 {
display: block;
font-size: 1.5em;
font-weight: bold;
margin-bottom: 0.67em;
margin-left: 0;
margin-right: 0;
margin-top: -1em;
text-align: center
}
.calibre4 {
display: block;
margin-bottom: 0;
margin-left: 1.25em;
margin-right: 0;
margin-top: 0;
text-align: justify
}
.pagerule-cls {
text-align: center;
font: 13px Arial, Helvetica, sans-serif;
}
</style>
</head>
<body style='margin-left:100px;margin-right:10px;min-width:400px;max-width:800px;'><a name='stagpage6' id='stagpage6'/><div class='pagerule-cls'>7</div>
<div><blockquote class="calibre4"><span>
<h1 class="calibre14"><span><span class="bold"><a></a>INTRODUCTION</span></span></h1>
<div></div></span></blockquote></div>
</body>
</html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最简单的方法是将
margin-bottom: 1em;
添加到.pagerule-cls
中,这可能会导致其他文档的边距过大。更好的方法是仅将这种额外的样式添加到相关文档中。你如何修改文档?您可以查询-1em
吗?The simplest way is to add
margin-bottom: 1em;
to.pagerule-cls
, which maybe would result in a too large margin for the other documents. Better is to add this extra style only to the document in question. How do you modify the documents? Could you query for the-1em
?