麻烦老师帮忙看下

来源:2-17 自由编程

ToExpress

2020-12-25 21:55:12

# 具体遇到的问题

感觉写的东西在网页上显示多了个边框

# 报错信息的截图

# 相关课程内容截图

# 尝试过的解决思路和结果

# 粘贴全部相关代码,切记添加代码注释(请勿截图)

在这里输入

<!DOCTYPE html>

<html lang="en">


<head>

  <meta charset="UTF-8">

  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>Document</title>

  <style>

    .big {


      height792px;

      background#07CBC9;

      margin0 auto;

      overflowhidden;

    }


    .all {

      width25%;

      height396px;

      floatleft;

      overflowhidden;

    }


    .spans {

      displayblock;

      font-size24px;

      font-weightbold;

      colorwhite;

      margin20px 20px 0;

    }


    .one2 button {

      background-colorblack;

      width138px;

      height40px;

      margin20px;

      margin-left130px;

      colorwhite;

      bordernone;

      overflowhidden;

    }


    .all .one {

      colorwhite;

      font-size16px;

      margin30px 20px 0px;

      overflowhidden;

      displayblock;

    }


    .all button {

      displayblock;

      margin30px auto;

      background-colorblack;

      width138px;

      height40px;

      colorwhite;

      bordernone;

      overflowhidden;

    }


    .all .p1 {

      width90%;

      margin-left40px;

      colorgray;

      margin20px 20px 0;

      

    }

    .big .all::before {

      content"";

      displayblock;

      width0;

      height0;

      border20px solid transparent;

      positionabsolute;

      top50%;

      margin-top:-198px;

      

    }

    

    .big .before::before {

      border-right-color#07cbc9;

     margin-left-40px;

      

    }

    .big .after::before {

      border-left-color#07cbc9;

      top100%;

      margin-top:-198px;

      margin-left:375px;

      

    }

  </style>

</head>


<body>

  <div class="big">

    <div class="one all">

      <img src="/Study/作业素材/images/b1.jpg">

    </div>

    <div class="one2 all before">

      <span class="spans">Library</span>

      <p>

        <span class="one">Ipsum is simply dummy text of the printing

          and typesetting industry</span></p>

      <p class="p1">Lorem Ipsum has been the industry's standard

        ever since the 1500s, when an unknown

        printer took a galley of type and scrambled it to make a

        type specimen book</p>

      <button>EXPLORE</button>

    </div>

    <div class="one3 all">

      <img src="/Study/作业素材/images/b2.jpg">

    </div>

    <div class="one4 all before">

      <span class="spans">Library</span>

      <p>

        <span class="one">Ipsum is simply dummy text of the printing

          and typesetting industry</span></p>

      <p class="p1">Lorem Ipsum has been the industry's standard

        ever since the 1500s, when an unknown

        printer took a galley of type and scrambled it to make a

        type specimen book</p>

      <button>EXPLORE</button>

    </div>

    <div class="one5 all after">

      <span class="spans">Library</span>

      <p>

        <span class="one">Ipsum is simply dummy text of the printing

          and typesetting industry</span></p>

      <p class="p1">Lorem Ipsum has been the industry's standard

        ever since the 1500s, when an unknown

        printer took a galley of type and scrambled it to make a

        type specimen book</p>

      <button>EXPLORE</button>

    </div>

    <div class="one6 all">

      <img src="/Study/作业素材/images/b3.jpg">

    </div>

    <div class="one7 all after">

      <span class="spans">Library</span>

      <p>

        <span class="one">Ipsum is simply dummy text of the printing

          and typesetting industry</span></p>

      <p class="p1">Lorem Ipsum has been the industry's standard

        ever since the 1500s, when an unknown

        printer took a galley of type and scrambled it to make a

        type specimen book</p>

      <button>EXPLORE</button>

    </div>

    <div class="one8 all">

      <img src="/Study/作业素材/images/b4.jpg">

    </div>

  </div>

</body>


</html>

​代码,可通过选择【代码语言】突出显示

写回答

1回答

好帮手慕久久

2020-12-26

同学你好,代码中有如下问题:

1、body等元素有默认的margin或padding样式:

http://img.mukewang.com/climg/5fe69cf00962a8d108110179.jpg

建议使用通配符选择器,去掉所有元素默认的边距样式,如下:

http://img.mukewang.com/climg/5fe69d15094cc10a04690157.jpg

2、全屏时,图片没有填充满父元素:

http://img.mukewang.com/climg/5fe69b90099344d006400700.jpg

原因是图片默认会按照原始大小来显示,不会按照父元素的大小来显示。

建议给图片设置宽高为100%,这样图片就会与父元素一样大了,如下:

http://img.mukewang.com/climg/5fe69cca090e3fd904110146.jpg

3、小三角形,只需要加在图片区或文字区,即总共只有4个三角形。同学的三角形是通过.big .all::before这个样式来实现的,这样会造成8组内容都有三角形。

建议将三角形,设置在.before和.after元素上,如下:

http://img.mukewang.com/climg/5fe69f1a090f545906210257.jpg

http://img.mukewang.com/climg/5fe6a00c094acce908420596.jpg

http://img.mukewang.com/climg/5fe6a01a09b1564105970521.jpg

4、优化建议:

图片的路径,建议改成./开头,如下:

http://img.mukewang.com/climg/5fe6a1a0098e6a2105080087.jpg

“/”开头的路径比较特殊,当使用服务器打开页面时(利用vscode编辑器的liver server插件打开页面),该路径才有效:

http://img.mukewang.com/climg/5fe6a208098bcab606880118.jpg

所以建议将“/”换成“./“(直接写“Study/作业素材/images/b4.jpg”也行),这样的路径更通用。

5、优化建议:每组图文上的类名.one~.one8是多余的,可以去除:

http://img.mukewang.com/climg/5fe6a1000986155505220486.jpg

祝学习愉快!


0
hoExpress
hp>好的,谢谢老师

h020-12-27
共1条回复

0 学习 · 15276 问题

查看课程