Html 此导航栏在不同浏览器中的输出不同,为什么要这样做?
我还在学习HTML和CSS,现在我正在练习导航栏。这段代码为Mozilla和Chrome显示了不同的填充,为什么要这样做?我不明白为什么这一事实真的很烦人。我将在这里分享代码Html 此导航栏在不同浏览器中的输出不同,为什么要这样做?,html,css,navigation,Html,Css,Navigation,我还在学习HTML和CSS,现在我正在练习导航栏。这段代码为Mozilla和Chrome显示了不同的填充,为什么要这样做?我不明白为什么这一事实真的很烦人。我将在这里分享代码 <!doctype html> <html> <head> <title>Practice</title> <style> /* ====== RESET CODE ======= */
<!doctype html>
<html>
<head>
<title>Practice</title>
<style>
/* ====== RESET CODE ======= */
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;
}
body {
font-family: arial;
}
#top {
width:100%;
height:40px;
background-color:#555;
}
.container {
margin:0 auto;
padding:0px;
width: 1000px;
}
#nav ul li {
float:left;
display:block;
margin:0px;
}
#search-bar {
float:right;
border: 1px solid;
width:315px;
position: relative;
top:5px;
}
.search {
width: 100%;
padding:2px;
}
a {
padding: 18px 12px;
color:#fff;
text-decoration:none;
margin:0px;
position: relative;
top:10px;
}
a:hover {
background-color:#777;
padding:11px 12px;
}
</style>
</head>
<body>
<div id="top">
<div class="container">
<div id="nav">
<ul>
<li><a href="#">Link</a></li>
<li><a href="#">Link Jupiter</a></li>
<li><a href="#">Link Venus</a></li>
<li><a href="#">Link Mars</a></li>
<li><a href="#">Link Neptune</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
</ul>
</div>
<div id="search-bar">
<input class="search" type="text" placeholder="search"/>
</div>
</div>
</div>
</body>
</html>
实践
/*=======重置代码========*/
html、正文、div、span、小程序、对象、iframe、,
h1、h2、h3、h4、h5、h6、p、块报价、预,
a、 缩写,首字母缩写,地址,大,引用,代码,
del、dfn、em、img、ins、kbd、q、s、samp、,
小、走向、强、次、辅助、tt、var、,
b、 u,i,中心,
dl,dt,dd,ol,ul,li,
字段集、表单、标签、图例、,
表格、标题、正文、tfoot、THAD、tr、th、td、,
文章、旁白、画布、细节、嵌入、,
图,figcaption,页脚,页眉,H组,
菜单、导航、输出、ruby、节、摘要、,
时间、标记、音频、视频{
保证金:0;
填充:0;
边界:0;
字体大小:100%;
字体:继承;
垂直对齐:基线;
}
/*旧浏览器的HTML5显示角色重置*/
文章,旁白,细节,图表,
页脚、页眉、H组、菜单、导航、节{
显示:块;
}
身体{
线高:1;
}
ol,ul{
列表样式:无;
}
区块报价,q{
报价:无;
}
blockquote:before,blockquote:after,
问:之前,问:之后{
内容:'';
内容:无;
}
桌子{
边界塌陷:塌陷;
边界间距:0;
}
身体{
字体系列:arial;
}
#顶{
宽度:100%;
高度:40px;
背景色:#555;
}
.集装箱{
保证金:0自动;
填充:0px;
宽度:1000px;
}
#李国荣{
浮动:左;
显示:块;
边际:0px;
}
#搜索栏{
浮动:对;
边框:1px实心;
宽度:315px;
位置:相对位置;
顶部:5px;
}
.搜索{
宽度:100%;
填充:2px;
}
a{
填充:18px 12px;
颜色:#fff;
文字装饰:无;
边际:0px;
位置:相对位置;
顶部:10px;
}
a:悬停{
背景色:#777;
填充:11px 12px;
}
所有浏览器都有自己的默认css。您试图在重置代码中重置默认css,但我认为您缺少一些元素。最好尝试以下重置代码:
* {
margin: 0;
padding: 0;
font-size: 12px;
line-height: 1;
zoom: 1;
font: inherit;
vertical-align: baseline;
}
使用导航条引导:- 您可以从以下站点下载引导程序: 使用引导时非常容易