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

看到一道面试题,如题,试着来做做,采用两种方法:法一,设几个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>






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值