css如何设置div子容器之间的间距

html-css077

css如何设置div子容器之间的间距,第1张

需要准备的材料分别有:电脑、浏览器、html编辑器。

1、首先,打开html编辑器,新建html文件,例如:index.html。

2、在index.html中的<style>标签中,输入css代码:.sub{margin-top: 30px}。

3、浏览器运行index.html页面,此时3个div子子容器的垂直间距被统一设置为了30px。

.nav .path, .nav .other { float:leftdisplay:inlinemargin-left:11pxline-height:32pxheight:32pxoverflow:hidden}

.nav .other { float:rightmargin-right:11pxmargin-left:0}你在上面已经同时定义了nav .path,nav .other ,为什么在下面还要定义nav .other 。你都混淆了,样式都乱了。margin-left:11px是定义左边距,margin-right:11px是定义右边距

给标签加word-spacing和letter-spacing就行了,word-spacing这个是数字、单词、汉字之间的间距;letter-spacing是字母之间的间距

一般这2个样式用的比较少,不过防止出问题设2个也没事,2个都设同样的值就好了