html+css网页开发实战 | 您所在的位置:网站首页 › html网页怎么加背景图 › html+css网页开发实战 |
网页成品图:
文字在div或者span的中间。 解决办法:定义了高度height之后,同样要定义line-height。它们两个的值要一致。 几个文字的布局问题。 解决方法:首先定义两个大的span,使他们分别左浮动和右浮动,并给它们之间margin-left的值调到合适。 html代码: 设为首页 收藏本站 2015年5月1日 多云16度/30度css代码: .title span.left{ height: 100%; width:300px; margin-left:100px; } .title span.right{ height: 100%; width:300px; margin-right:100px; }然后里面小的span,同样添加上不同的类名,在css里面定义宽度,并且设置了margin-left。代码如下: .title span.shouye{ width:150px; height:100%; margin-left:40px; } .title span.shouchang{ width:150px; height:100%; margin-left:40px; } .title span.tianqi{ width:150px; height:100%; margin-right:40px; } .title span.riqi{ width:150px; height:100%; margin-right:40px; }最后,在去掉a标签的默认样式即可,代码如下: title span a{ text-decoration: none; color:#D8D8D8; }成品图如下所示: htm代码 设为首页 收藏本站 2015年5月1日 多云16度/30度css代码 .top{ width:100%; height:24px; line-height:24px; background:#303030; color:##D8D8D8; } .top span{ margin-right:15px; } .top span.mr_0{ margin:0px; } .top a{ color:#D8D8D8; text-decoration: none; } .top a:hover{ color:#F60; }我们之间的区别总结: 它命名为top,我命名为title。 它使用了两个大的div作为父容器,我使用了两个大的span。 比较:我觉得它做得好,div作为容器的话,因为它是行间元素,所以不用指定它的大小,一行里有多大它填多大。 它在每一个span里使用的是margin-right,我使用的时margin-left. 比较:我觉得它的更方便 它在最右边有关天气的span里加了一个类mr_0。去除了最右边的边距。 class=“mr_0”: .top span.mr_0{ margin:0px; }总结:老师写的布局更加简洁,作为一个新手要多学习老师的这种写法 |
CopyRight 2018-2019 实验室设备网 版权所有 |