为什么图片底下的文字无法相对于图片居中
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS布局</title>
<style type="text/css">
.middel{width:800px;margin:0,auto;}
.middle-head{margin-left:400px;}
.image01{width:30%;float:left;margin-right:10px;}
.image02{width:30%;float:left;}
.text01.text02{width:100%;margin-left:150px;}
</style>
</head>
<body>
<div class="middle">
<div class="middle-head">
ENJOT THE LIFE
</div>
<div class="middle-image">
<div class="image01">
<img src="http://img1.sycdn.imooc.com/climg//58f829090001a4b504260240.jpg"/>
<div class="text-01">we had join we have <br>
we had seson in the sun
</div>
</div>
<div class="image02"><img src="http://img1.sycdn.imooc.com/climg//58f8290f0001558804260240.jpg"/>
<div class="text-02">
we had join we have <br>
we had seson in the sun
</div>
</div>
</div>
</div>
</body>
</html>
19
收起
正在回答
2回答
可以呀,但是你的css中,text01和text02的类名和html中定义的不一致,其次,如果你想同时对2个选择器定义,中间要加逗号。最后因为有外边距的存在,即使文字在text01和text02内居中了,也不会和图片居中对齐的,需要你接着慢慢调试。

继续加油吧~~
前端小白入门系列课程
- 参与学习 人
- 提交作业 11218 份
- 解答问题 36712 个
从一个不会编程的小白到一个老司机是需要过程的,首先得入门,学习基础知识,然后才能进阶,最后再到精通,本专题是你走进前端世界的不二选择!
了解课程

恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星