一道前端代码题,用很简单的CSS代码实现

昨天去第一次面试前端这个岗位,有点新奇,去到那里技术就给了我一个电脑,一张设计图让用sublime敲出来。

设计图大概长这样吧,因为不能拍照,所以这是我回家后做的。

<!DOCTYPE html>
<html>
<head>
	<title>hello</title>
	<style type="text/css">
	.container{
		background-color: #eee;
		padding: 20px
	}
	.box-group{
		display: flex;
		justify-content: space-around;
		flex-direction: row;
		flex-wrap: wrap;
	}
	.box{
		background-color: #fff;
		height: 150px;
		width: 230px;
		padding: 20px;
		display: flex;
		justify-content: space-between;
		flex-direction: column;
	}
	.box .title-group{
		display: flex;
		color: #878787;
		justify-content: space-between;
	}
	.box .title-group .title{
		font-size: 14px;
	}
	/*!的icon*/
	.box .title-group .icon{
		width: 15px;
		height: 15px;
		display: block;
		border: 1px solid #878787;
		border-radius: 50%;
		line-height: 15px;
		text-align: center;
	}
	.price{
		font-size: 26px;
	}
	/*一个向下的箭头*/
	.red {
		font-size: 0;
		line-height: 0;
		border-width: 10px;
		border-color: red;
		border-bottom-width: 0;
		border-style: dashed;
		border-left-color: transparent;
		border-right-color: transparent;
	}
	/*一个向上的箭头*/
	.green{
		font-size: 0;
		line-height: 0;
		border-width: 10px;
		border-color: green;
		border-top-width: 0;
		border-style: dashed;
		border-left-color: transparent;
		border-right-color: transparent;
	}
	.per-group{
		display: flex;
		justify-content: space-between;
	}
	</style>
</head>
<body>
<section class="container">
<!-- 创建一个容器 -->
	<div class="box-group">
	<!-- 一个四个一模一样的盒子 -->
		<div class="box">
			<div class="title-group">
				<span class="title">销售额</span>
				<span class="icon">!</span>
			</div>
			<div class="price">
				¥12478.8
			</div>
			<div class="per-group">
				<div>周比<span class="green"></span>12</div>
				<div>日比<span class="red"> </span>45</div>
			</div>
			<div class="date">
				时间 &nbsp;20200421
			</div>
		</div>
		<div class="box">
			<div class="title-group">
				<span class="title">销售额</span>
				<span class="icon">!</span>
			</div>
			<div class="price">
				¥12478.8
			</div>
			<div class="per-group">
				<div>周比<span class="green"></span>12</div>
				<div>日比<span class="red"> </span>45</div>
			</div>
			<div class="date">
				时间 &nbsp;20200421
			</div>
		</div>
		<div class="box">
			<div class="title-group">
				<span class="title">销售额</span>
				<span class="icon">!</span>
			</div>
			<div class="price">
				¥12478.8
			</div>
			<div class="per-group">
				<div>周比<span class="green"></span>12</div>
				<div>日比<span class="red"> </span>45</div>
			</div>
			<div class="date">
				时间 &nbsp;20200421
			</div>
		</div>
		<div class="box">
			<div class="title-group">
				<span class="title">销售额</span>
				<span class="icon">!</span>
			</div>
			<div class="price">
				¥12478.8
			</div>
			<div class="per-group">
				<div>周比<span class="green"></span>12</div>
				<div>日比<span class="red"> </span>45</div>
			</div>
			<div class="date">
				时间 &nbsp;20200421
			</div>
		</div>
	</div>
</section>
</body>
</html>

 面试的时候我是用relative+position做的,不过会变形,所以试着用flexbox做了一下。

新手一枚,大神不要喷我哦

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值