2-13练习题,请老师指点,谢谢!
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
<!--
body{margin:0;padding:0;}
.con{
width:80%;
text-align:center;
margin:0 auto;
padding-top:100px;
}
.fir_line{
background:#2ef;
width:100%;
height:500px;
position:relative;
}
.fir_line div{
width:360px;
height:214px;
position:absolute;
top:50%;
margin-left:-180px;
margin-top:-107px;
}
.big_left{left:30%;}
.big_right{left:70%;}
.sec_line{
width:100%;
height:200px;
background:pink;
position:relative;
}
.sec_line div{
width:200px;
height:60px;
position:absolute;
top:50%;
margin-left:-100px;
margin-top:-30px;
}
.sma_left{left:20%;}
.sma_middle{left:50%;}
.sma_right{left:80%;}
-->
</style>
</head>
<body>
<div class="con">
<div class="fir_line">
<div class="big_left">
<img src="http//img1.sycdn.imooc.com/climg//58c0f808000129a303600215.jpg"/>
</div>
<div class="big_right">
<img src="http//img1.sycdn.imooc.com/climg//58c0f819000198a703600214.jpg"/>
</div>
</div>
<div class="sec_line">
<div class="sma_left">
<img src="http//img1.sycdn.imooc.com/climg//58c0f81d0001fe4402000060.jpg"/>
</div>
<div class="sma_middle">
<img src="http//img1.sycdn.imooc.com/climg//58c0f8220001dfce02000060.jpg"/>
</div>
<div class="sma_right">
<img src="http//img1.sycdn.imooc.com/climg//58c0f8780001c74602000060.jpg"/>
</div>
</div>
</div>
</body>
</html>另外,老师,想请问一句,在div包裹img图片的时候,怎么在div容器不设定宽度和高度的时候使图片自动填充?
20
收起
正在回答
1回答
问题如下:
图片src缺少http
当网页缩小时,会出现重叠,所以给 .con设置min-width: 1000,使到一定宽度不在变化。
代码建议,不设置宽高:
<div class="fir_line"> <img src="http://img1.sycdn.imooc.com/climg//58c0f808000129a303600215.jpg"/> <img src="http://img1.sycdn.imooc.com/climg//58c0f819000198a703600214.jpg"/> </div>
css:
.fir_line{
background:#2ef;
}
img{margin:50px;}
前端小白入门系列课程
- 参与学习 人
- 提交作业 11218 份
- 解答问题 36712 个
从一个不会编程的小白到一个老司机是需要过程的,首先得入门,学习基础知识,然后才能进阶,最后再到精通,本专题是你走进前端世界的不二选择!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星