Eri*_*rik 6 javascript css printing page-break-inside
我有以下伪代码:
<!doctype html>
<html>
<head>
<style>
p {font-size: 20px;}
</style>
</head>
<body>
<script type="text/javascript">
window.onload = function () {
var body = document.getElementsByTagName('body')[0],
p = document.createElement('p'),
el;
p.style.height = '20px';
p.innerText = 'Some Test';
for (var i = 0, len=30; i<len; i++) {
el = p.cloneNode(true);
body.appendChild(el);
}
};
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
它呈现了一些
元素和页面预览中的外观如下: 
我需要在第一个和最后一个元素上添加边框,如下所示: 
是否可以通过使用CSS进行制作并在Webkit中进行工作?
编辑:给建议以下css的每个人
p:nth-child(1){
border-top : solid 1px gray;
}
p:last-child{
border-top : solid 1px gray;
}
Run Code Online (Sandbox Code Playgroud)
要么
p:first-child {border-top : solid 1px gray;}
p:last-child {border-bottom : solid 1px gray;}
Run Code Online (Sandbox Code Playgroud)
那对我不起作用,因为它遍及所有页面并且看起来像这样: 
我需要在Chrome中工作
Nit*_*esh -3
尝试first-child并last-child。
例如,
p {font-size: 20px;}
p:first-child {...} /* Add your desired style here */
p:last-child {...} /* Add your desired style here */
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1831 次 |
| 最近记录: |