检查代码,看看有没有优化的地方。
来源:2-7 编程练习
weixin_慕的地5241954
2019-08-17 00:32:28
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>CSS布局</title> <style type="text/css"> /*此处写代码*/ *{ margin: 0; padding: 0; } .content{ width: 1000px; margin: 0 auto; } .content .tittle{ text-align: center; font: bold 26px Serif; margin-top: 50px; } .content .pic-con{ margin-left: 150px; } .content .pic-con dl{ float: left; width: 360px; margin: 10px 15px; } .content .pic-con dl img{ width: 360px; } .content .pic-con dl dd{ font: bold 14px Serif; } .clear{ clear: both; } </style> </head> <body> <!-- 此处写代码 --> <div class="content"> <div class="tittle">ENJOY THE LIFE</div> <div class="pic-con"> <dl> <dt><img src="http://climg.mukewang.com/58f829090001a4b504260240.jpg"></dt> <dd> Life is like a book,just read more and more refined,more write more carefully. When read,mind open,all things have been indiferent to heart.Life is the precipitation. </dd> </dl> <dl> <dt><img src="http://climg.mukewang.com/58f8290f0001558804260240.jpg"></dt> <dd> Life is like a book,just read more and more refined,more write more carefully. When read,mind open,all things have been indiferent to heart.Life is the precipitation. </dd> </dl> <div class="clear"></div> </div> <div class="clear"></div> </div> </body> </html>
1回答
同学你好,从下图中可以看出标题下的内容没有实现水平居中,为了效果更美观,建议居中显示。
建议:外层盒子的宽度可以设置为内容的总宽度。
代码参考:
祝学习愉快~
相似问题
回答 1
回答 2