3-4编程练习不能按效果图呈现???

3-4编程练习不能按效果图呈现???

<!DOCTYPE html>
<html>
<head>
        <!-- 此处编写样式 -->
        <meta charset="UTF-8">
        <title>Document</title>
        <style>
           *{
                padding:0px;
                margin:0px;
            }
            .main{
                border:2px dashed gray;
                width:800px;
                height:400px;
                /*overflow:hidden;
                zoom:1;*/
            }
            .a{
                overflow:hidden;
                zoom:1;
            }
            .a>div{
                width:200;
                height:100;
                font-family:"微软雅黑";
                float:left;
                margin:20px 10px;
            }
            .b{
                overflow:hidden;
                zoom:1;
            }
            .b>div{
                width:200;
                height:100;
                font-family:"微软雅黑";
                float:left;
                margin:20px 10px;
            }
        </style>
</head>
<body>   
        <!-- 此处写代码 -->
        <div class="main">
            <div class="a">
            <div class="a1">
            <img scr="http://img1.sycdn.imooc.com/climg//590fe9770001e63102400135.jpg"/>
            <div>欢迎来到慕课网学习新知识</div>
            </div>
            <div class="a2">
            <img scr="http://img1.sycdn.imooc.com/climg//590fe97d00011bda02400135.jpg"/>
            <div>欢迎来到慕课网学习新知识</div>
            </div>
            <div class="a3">
            <img scr="http://img1.sycdn.imooc.com/climg//590fe982000150ba02400135.jpg"/>
            <div>欢迎来到慕课网学习新知识</div>
            </div>
            </div>
            <div class="b">
            <div class="b1">
            <img scr="http://img1.sycdn.imooc.com/climg//590fe9770001e63102400135.jpg"/>
            <div>欢迎来到慕课网学习新知识</div>
            </div>
            <div class="b2">
            <img scr="http://img1.sycdn.imooc.com/climg//590fe97d00011bda02400135.jpg"/>
            <div>欢迎来到慕课网学习新知识</div>
            </div>
            <div class="b3">
            <img scr="http://img1.sycdn.imooc.com/climg//590fe982000150ba02400135.jpg"/>
            <div>欢迎来到慕课网学习新知识</div>
            </div>
            </div>
        </div>
</body>
</html>


正在回答

登陆购买课程后可参与讨论,去登陆

5回答

1、图片的宽度是240,外边距宽20,边框宽2px,,240*3+20*4+2*6=812px;同学把815px改成812px 也可以的。

http://img1.sycdn.imooc.com//climg/5b9dbe4b0001d08c08130411.jpg

2、高度同理。

看图片的宽度同学可以把鼠标放在图片上可以看到它的宽高,同学也可以自己设置宽高。

3、 是的,margin:20px 0px 0px 20px 一个是top外边距,一个是left外边距。

4、http://img1.sycdn.imooc.com//climg/5b9dc19a0001690d03210181.jpg

在浏览器端按F12调出上图中的部分,按一下红框中的按钮,使其变成蓝色,此时你的鼠标放在图片上时,会展示其大小


如果我的回答解决了你的问题,请采纳,祝学习愉快.

  • 慕羲 提问者 #1
    欢迎来到慕课网学习新知识,这句话的高 度是(390-135*2-20*3-2*4)/2=26,对不对???
    2018-09-16 17:45:20
  • 好帮手慕阿莹 回复 提问者 慕羲 #2
    是的。同学理解的没错
    2018-09-17 11:00:59
chrismorgen 2018-09-13 15:50:54

大体的模样已经有了,我们就可以对main的宽高和图片之间的margin属性进行调节了,针对你的代码做了一些调整,同学可以和自己的代码核对一下:

<!DOCTYPE html>
<html>
<head>
        <!-- 此处编写样式 -->
        <meta charset="UTF-8">
        <title>Document</title>
        <style>
           *{
                padding:0px;
                margin:0px;
            }
            .main{
                border:2px dashed gray;
                width:815px;
                height:390px;
                /*overflow:hidden;
                zoom:1;*/
            }
            .a{
                overflow:hidden;
                zoom:1;
            }
            .a>div{
                /*width:200px;
                height:100px;*/
                border:2px solid gray;
                font-family:"微软雅黑";
                float:left;
                margin:20px 0px 0px 20px;
            }
            .b{
                overflow:hidden;
                zoom:1;
            }
            .b>div{
                /*width:200px;
                height:100px;*/
                border:2px solid gray;
                font-family:"微软雅黑";
                float:left;
                /*margin:0px 10px;*/
                margin:20px 0px 0px 20px;
            }
        </style>
</head>
<body>   
        <!-- 此处写代码 -->
        <div class="main">
            <div class="a">
            <div class="a1">
            <img src="http://img1.sycdn.imooc.com/climg//590fe9770001e63102400135.jpg"/>
            <div>欢迎来到慕课网学习新知识!</div>
            </div>
            <div class="a2">
            <img src="http://img1.sycdn.imooc.com/climg//590fe97d00011bda02400135.jpg"/>
            <div>欢迎来到慕课网学习新知识!</div>
            </div>
            <div class="a3">
            <img src="http://img1.sycdn.imooc.com/climg//590fe982000150ba02400135.jpg"/>
            <div>欢迎来到慕课网学习新知识!</div>
            </div>
            </div>
            <div class="b">
            <div class="b1">
            <img src="http://img1.sycdn.imooc.com/climg//590fe9770001e63102400135.jpg"/>
            <div>欢迎来到慕课网学习新知识!</div>
            </div>
            <div class="b2">
            <img src="http://img1.sycdn.imooc.com/climg//590fe97d00011bda02400135.jpg"/>
            <div>欢迎来到慕课网学习新知识!</div>
            </div>
            <div class="b3">
            <img src="http://img1.sycdn.imooc.com/climg//590fe982000150ba02400135.jpg"/>
            <div>欢迎来到慕课网学习新知识!</div>
            </div>
            </div>
        </div>
</body>
</html>

修订之后的效果如下:

http://img1.sycdn.imooc.com//climg/5b9a16d90001af2708460419.jpg

  • 提问者 慕羲 #1
    width:815; height:390; 是怎么计算出来的,怎么知道图片的大小,我没有设置图片的大小? margin:20px 0px 0px 20px;怎么理解,一个是top外边距,一个是left外边距吗?
    2018-09-14 19:25:51
提问者 慕羲 2018-09-13 14:32:08

http://img1.sycdn.imooc.com//climg/5b9a040b0001ca6813660605.jpg

修改了,跟效果图不太一样???

<!DOCTYPE html>
<html>
<head>
        <!-- 此处编写样式 -->
        <meta charset="UTF-8">
        <title>Document</title>
        <style>
           *{
                padding:0px;
                margin:0px;
            }
            .main{
                border:2px dashed gray;
                width:800px;
                height:400px;
                /*overflow:hidden;
                zoom:1;*/
            }
            .a{
                overflow:hidden;
                zoom:1;
            }
            .a>div{
                /*width:200px;
                height:100px;*/
                border:2px solid gray;
                font-family:"微软雅黑";
                float:left;
                margin:20px 10px;
            }
            .b{
                overflow:hidden;
                zoom:1;
            }
            .b>div{
                /*width:200px;
                height:100px;*/
                border:2px solid gray;
                font-family:"微软雅黑";
                float:left;
                margin:20px 10px;
            }
        </style>
</head>
<body>   
        <!-- 此处写代码 -->
        <div class="main">
            <div class="a">
            <div class="a1">
            <img src="http://img1.sycdn.imooc.com/climg//590fe9770001e63102400135.jpg"/>
            <div>欢迎来到慕课网学习新知识!</div>
            </div>
            <div class="a2">
            <img src="http://img1.sycdn.imooc.com/climg//590fe97d00011bda02400135.jpg"/>
            <div>欢迎来到慕课网学习新知识!</div>
            </div>
            <div class="a3">
            <img src="http://img1.sycdn.imooc.com/climg//590fe982000150ba02400135.jpg"/>
            <div>欢迎来到慕课网学习新知识!</div>
            </div>
            </div>
            <div class="b">
            <div class="b1">
            <img src="http://img1.sycdn.imooc.com/climg//590fe9770001e63102400135.jpg"/>
            <div>欢迎来到慕课网学习新知识!</div>
            </div>
            <div class="b2">
            <img src="http://img1.sycdn.imooc.com/climg//590fe97d00011bda02400135.jpg"/>
            <div>欢迎来到慕课网学习新知识!</div>
            </div>
            <div class="b3">
            <img src="http://img1.sycdn.imooc.com/climg//590fe982000150ba02400135.jpg"/>
            <div>欢迎来到慕课网学习新知识!</div>
            </div>
            </div>
        </div>
</body>
</html>

还要怎么修改好一些呢???

好帮手慕阿莹 2018-09-12 17:18:38

1、你的.a>div   .b>div 宽和高都没有写px。

2、图片引入的是src ,同学拼写成scr了

3、适当调整一下 .a>div 和  .b>div 的 宽高

4、 .a>div 和  .b>div里的样式设置一样,你可以写个共同的类名,然后写一次就好了。

如果我的回答解决了你的疑惑,请采纳!祝学习愉快!


  • 提问者 慕羲 #1
    请看下一上面的截图,跟效果图不太一样,要怎么修改好一些???
    2018-09-13 14:33:06
chrismorgen 2018-09-12 17:13:14

你的<img src>中的scr写错了,应改为src,祝学习愉快~

问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
从网页搭建入门Java Web2018版
  • 参与学习           人
  • 提交作业       1088    份
  • 解答问题       10205    个

如果你有Java语言基础,又想以后从事Java Web开发,那么本路径是你的不二选择!本路径从网页搭建开始入手,通过大量案例来学习Java Web基础。定能助你完成Java Web小白的蜕变!

了解课程
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师