关于2-7练习
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>CSS布局</title> <style type="text/css"> .title{ padding-top:50px; text-align:center; font:bolder 15px "微软雅黑" ; } .container{ width:1000px; margin:0 auto; } .div1,.div2{ width:450px; padding: 10px 10px; float:left; text-align: center; } img{ width:450px; } .clear{ clear:both; } dd{ padding: 0 0; text-align:left; } </style> } } </head> <body> <div> <div class="title"> ENJOY THE LIFE </div> <div class="container"> <div class="div1"> <dl> <dt><img src="http://img1.sycdn.imooc.com/climg//58f829090001a4b504260240.jpg"/></dt> <dd>Life is like a book, just read more and more refined, more write more carefuliy. when read, mind open, all things have been indifferent to heart. Life is the precipitation.</dd> </dl> </div> <div class="div2"> <dl> <dt><img src="http://img1.sycdn.imooc.com/climg//58f8290f0001558804260240.jpg"/></dt> <dd>Life is like a cup of tea, let people lead a person to endless aftertastes. You again good taste, it will always have a different taste, different people will have different taste more.</dd> </dl> </div> <div class="clear"></div> </div> </div> </body> </html>
请问老师关于1.我的代码无论我怎么调试 图片下方字体距容器左边为什么有一定的距离
2.为什么我的居中效果和老师给的效果不一样
24
收起
正在回答
3回答
37、38行多的 }
关于text-align,margin:0 auto理解基本正确,但是注意细节,当子元素和父元素的宽度一样时,margin:0 auto的效果时看不出来的。
设置text-align的容器,内部的图片也有效果。
动手实践,加油。
hy_wang
2017-12-14 22:35:31
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>CSS布局</title> <style type="text/css"> .title{ padding-top:50px; text-align:center; font:bolder 15px "微软雅黑" ; } .container{ width:1000px; margin:0 auto; } .div1,.div2{ width:450px; padding: 10px 10px; float:left; text-align: center; } img{ width:400px; } .clear{ clear:both; } dd{ width:400px; text-align: left; margin:0 auto; } </style> } } </head> <body> <div> <div class="title"> ENJOY THE LIFE </div> <div class="container"> <div class="div1"> <dl> <dt><img src="http://img1.sycdn.imooc.com/climg//58f829090001a4b504260240.jpg"/></dt> <dd>Life is like a book, just read more and more refined, more write more carefuliy. when read, mind open, all things have been indifferent to heart. Life is the precipitation.</dd> </dl> </div> <div class="div2"> <dl> <dt><img src="http://img1.sycdn.imooc.com/climg//58f8290f0001558804260240.jpg"/></dt> <dd>Life is like a cup of tea, let people lead a person to endless aftertastes. You again good taste, it will always have a different taste, different people will have different taste more.</dd> </dl> </div> <div class="clear"></div> </div> </div> </body> </html> 老师我将代码修改成了这个样子,请问现在效果可以吗,我想请问老师关于居中text-align:center和margin:0 auto分别有什么区别,是不是margin是针对块级元素在父容器中居中显示而text-align是让容器内的文本居中针对容器内的文本而言()
,请问老师我的理解对吗,还有老师align对于图片有效果吗
前端小白入门系列课程
- 参与学习 人
- 提交作业 11218 份
- 解答问题 36713 个
从一个不会编程的小白到一个老司机是需要过程的,首先得入门,学习基础知识,然后才能进阶,最后再到精通,本专题是你走进前端世界的不二选择!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星