抛开table布局,我们也能实现单线边框

1、前端项目中,“单线边框”列表已是屡见不鲜:

采用table布局,实现起来难度不大,如果抛开table布局呢?下面我们就来尝试一下

2、先上图,看最终效果:


3、html代码:

<!-- 列表容器 -->
	<div class="list-wrapper">
		<ul class="list-content">
			<li>1</li>
			<li>2</li>
			<li>3</li>
			<li>4</li>
			<li>5</li>
			<li>6</li>
			<li>7</li>
			<li>8</li>
			<li>9</li>
			<li>10</li>
		</ul>
	</div>

4、css代码,margin-right的妙用

*{
	margin: 0;
	padding: 0;
	list-style: none;
	box-sizing: border-box;
}

.list-wrapper{
	width: 1000px;
	height: 400px;
	border: 1px solid #e4393c;
	margin: 50px auto;
	overflow: hidden;
}

.list-content{
	display: block;
	width: 800px;
	height: 120px;
	overflow: hidden; 
	/* 设置padding-top: 1px,否则第一排列表的上边框会被隐藏 */
	padding: 1px 0 0 0; 
    margin:100px;
}

.list-content li{
	float: left;
	width: 100px;
	height: 60px;
	line-height: 60px;
	text-align: center;
	font-size: 25px;
	font-weight: bold;
	border: 1px solid #317ef3;
	/* 
	 * 设置margin-top和margin-right,隐藏两个列表重合的上边框和右边框 
	 * 
	 */
	margin: -1px -1px 0 0;
}




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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值