I’m trying to put a list into a div, while using * to eliminate unwanted space within and around the div. By doing this, the lists are no longer staying in the div. What do I need to do to get the list numbers inside of the div?
以下是您可能想要告诉学生的内容:
问题是您设置的*(universal selector)规则正在重置默认浏览器样式.
大多数浏览器都有一组用于呈现HTML文档的默认样式.以下是W3C推荐的默认样式列表:
从该文档可以看出,鼓励浏览器为ul和ol元素创建顶部和底部边距.
blockquote, ul,
fieldset, form,
ol, dl, dir,
menu { margin: 1.12em 0 }
还鼓励他们设置这些默认值:
ol, ul, dir,
menu, dd { margin-left: 40px }
ol { list-style-type: decimal }
ol ul, ul ol,
ul ul, ol ol { margin-top: 0; margin-bottom: 0 }
请注意,某些浏览器可能使用填充而不是边距.
因此,当您设置此规则时…
* {
margin: 0px;
padding: 0px
}
但你写道:
I’m trying to put a list into a div, while using * to eliminate unwanted space within and around the div.
那么为什么不专注于div呢?你为什么要定位所有元素?
也许这就是你想要的:
div {
margin: 0;
padding: 0;
}
.wrapper {
width: 85%;
margin-right: auto;
margin-left: auto;
}
.div1 {
background-color: green;
padding: 10px;
}
div {
margin: 0;
padding: 0;
}
Famous Dishes
- Baden-Württemberg
- Maultaschen
- Brenntar
- Sauerbraten
- Sauerkraut
- Spätzle, Knöpfle
- Weißwürste
- Weizenbier/Weißbier
- Helles Bier
- Radler
- Buletten
- Currywurst
- Eierkuchen
- Eisbein