WEB前端面试题 分别使用2个、3个、5个DIV画出一个大的红十字

版权声明:转载请注明出处 http://blog.csdn.net/yezhongdefeng https://blog.csdn.net/YeZhongDeFeng/article/details/78454373

看到一道面试题,如题,试着来做做,采用两种方法:法一,设几个DIV,再调;法二,按照参考书上的做法。

法一:(方法不一定好,欢迎多多交流。)

<!DOCTYPE html>
<!--两个DIV-->
<html>
<body>
<div style="width:100%;height:200px;margin-top:500px;location:center;border:none;background-color:red;position:absolute">
</div>
<div style="width:16%;height:1000px;margin-left:42%;margin-right:42%;margin-top:0px;border:none;background-color:red;style=clear:both;position:absolute">
</div>
</body>
</html>
<!DOCTYPE html>
<!--三个DIV-->
<html>
<body>
<div style="width:100%;height:100px;margin-top:500px;location:center;border:none;background-color:red;position:absolute"></div>
<div style="width:100%;height:100px;margin-top:400px;location:center;border:none;background-color:red;position:absolute"></div>
<div style="width:16%;height:1000px;margin-left:42%;margin-right:42%;margin-top:0px;border:none;background-color:red;position:absolute">
</div>
</body>
</html>
<!DOCTYPE html>
<!--五个DIV-->
<html>
<body>
<div style="width:100%;height:65px;margin-top:500px;location:center;border:none;background-color:red;position:absolute"></div>
<div style="width:100%;height:65px;margin-top:435px;location:center;border:none;background-color:red;position:absolute"></div>
<div style="width:100%;height:65px;margin-top:370px;location:center;border:none;background-color:red;position:absolute"></div>
<div style="width:8%;height:1000px;margin-left:42%;margin-right:50%;margin-top:0px;border:none;background-color:red;position:absolute"></div>
<div style="width:8%;height:1000px;margin-left:49%;margin-right:42%;margin-top:0px;border:none;background-color:red;position:absolute"></div>
</body>
</html>
法二:

具体思想为:两个,用DIV创建一个矩形,然后复制一个,以中心点旋转90度,两个合并;三个,用DIV创建一个矩形,然后复制一个,以中心点旋转90度,两个合并,然后在外面包一个空的DIV盒子;五个,红十字标志由五个正方形组成,代表五大洲,画一个正方形,然后复制成五个,再将五个正方形摆放好位置,组成红十字形状,圈选五个正方形之后,选择焊接选项,再填充红色(C:0,M:100,Y:100,K:0),去除边框颜色即可。

<!DOCTYPE html>
<!--两个DIV-->
<html>
<body>
<div style="width:1000px;height:200px;margin-left:180px;margin-top:500px;location:center;border:none;background-color:red;position:absolute"></div>
<div style="width:1000px;height:200px;margin-left:180px;margin-top:500px;location:center;border:none;background-color:red;position:absolute;transform:rotate(90deg);"></div>
</body>
</html>
<!DOCTYPE html>
<!--三个DIV-->
<html>
<body>
<div type="margin:auto">
<div style="width:1000px;height:200px;margin-left:180px;margin-top:500px;location:center;border:none;background-color:red;position:absolute"></div>
<div style="width:1000px;height:200px;margin-left:180px;margin-top:500px;location:center;border:none;background-color:red;position:absolute;transform:rotate(90deg);"></div>
</div>
</body>
</html>
<!DOCTYPE html>
<!--五个DIV-->
<html>
<body>
<div style="width:200px;height:200px;margin-left:500px;margin-top:100px;border:none;background-color:red;position:absolute"></div>
<div style="width:200px;height:200px;margin-left:300px;margin-top:300px;border:none;background-color:red;position:absolute"></div>
<div style="width:200px;height:200px;margin-left:500px;margin-top:300px;border:none;background-color:red;position:absolute"></div>
<div style="width:200px;height:200px;margin-left:700px;margin-top:300px;border:none;background-color:red;position:absolute"></div>
<div style="width:200px;height:200px;margin-left:500px;margin-top:500px;border:none;background-color:red;position:absolute"></div>
</body>
</html>






猜你喜欢

转载自blog.csdn.net/YeZhongDeFeng/article/details/78454373
今日推荐