你如何缩短html中的断行高度?

时间:2017-09-06 05:02:31

标签: html line-breaks

我正在尝试使用代码为我的虚假网页创建一个好标题:

<br>  
<h1>Adults For Kids</h1>  
<h2>Bring hope to those with none</h2>  
<br>  

但是当它运行时,文本周围有太多的空间,并且在没有空格的情况下没有足够的空白区域,那么如何缩短html中的断行高度?

2 个答案:

答案 0 :(得分:1)

<br>  
<h1>Adults For Kids</h1>  
<h2>Bring hope to those with none</h2>  
<br>

目前<br>不影响<h1><h2>之间的空间,它需要介于两个元素之间,如下所示: -

<h1>Adults For Kids</h1>
<br>  
<h2>Bring hope to those with none</h2>

或者您可以使用padding示例: -

<h1 style="padding-bottom:2px">Adults For Kids</h1>
<h2>Bring hope to those with none</h2>

padding-bottompadding-toppadding-leftpadding-right

如果您想在<h1>和页面顶部之间留出空格,可以执行以下操作: -

<h1 style="padding-bottom:2px; padding-top:5px">Adults For Kids</h1>
<h2>Bring hope to those with none</h2>

答案 1 :(得分:0)

由于HTML的每个标记都带有自己的默认属性,如边距和填充。 您可以使用Meyer重置将所有内容设置为默认值。

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
	margin: 0;
	padding: 0;
	border: 0;
	font-size: 100%;
	font: inherit;
	vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
	display: block;
}
body {
	line-height: 1;
}
ol, ul {
	list-style: none;
}
blockquote, q {
	quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
	content: '';
	content: none;
}
table {
	border-collapse: collapse;
	border-spacing: 0;
}

将它放在你的CSS代码中,每个东西都会设置为默认值,就像标题和段落的所有边距和填充以及它们的行高。你应该指定一切自定义CSS。