html中列表显示,html – * css规则正在改变我的列表在div中的显示方式

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
  1. Maultaschen
  2. Brenntar
  3. Sauerbraten
  4. Sauerkraut
  5. Spätzle, Knöpfle
Bavaria
  1. Weißwürste
  2. Weizenbier/Weißbier
  3. Helles Bier
  4. Radler
Berlin
  1. Buletten
  2. Currywurst
  3. Eierkuchen
  4. Eisbein
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值