问题描述
我使用了html5标题标签和一个h1标签。在我的标题中将h1元素的top margin属性设置为0px后,我设法删除了标题的顶部边界,但是我想让标题中的h1元素具有大约15px的顶部边距。
现在,当我尝试设置h1元素的顶部边距时,它也为头部创建了一个我不想要的顶部边距。
有人可以帮我解决这个问题吗?
解决方案使用 padding-top c> h1 或标题或使用 overflow:hidden 为头
I have made use of the html5 header tag and an h1 tag within it. After setting up the top margin property of the h1 element in my header to 0px, i manage to remove the top margin of the header, but i want the h1 element inside my header to have a top margin of around 15px.
Now when i try setting the top margin of the h1 element, it also creates a top margin for the header which i don't want.
Can someone help me out with this...?
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <link href="normalize.css" rel="stylesheet"> <link href="style.css" rel="stylesheet"> <title>Codename : ENT</title> </head> <body> <header> <h1>Site Title / LOGO</h1> <p>Site Tagline / Slogan / One liner.</p> <p></p> <nav></nav> </header> <div id="content_wrapper"></div> <footer> </footer> </body> </html>and CSS
header { background-color:#ff0 } header h1 { margin-top:0; margin-left:15px } header p { margin-left:15px }解决方案Use padding-top for h1 or header or use overflow:hidden for header
这篇关于设置标题中h1元素的上边距不能按预期工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-26 23:02