HTML——浮动布局案例

  1. 案例


    <!DOCTYPE html>
    <html>
    	<head>
    		<meta charset="utf-8">
    		<title></title>
    		<style>
    			/* 去除所有标签默认的编剧 */
    			*{
    				margin: 0;
    				padding: 0;
    			}
    			#box{
    				/* background-color: palegoldenrod; */
    				border: solid 1px white;
    			}
    			#box > h3{
    				margin: 10px 0;
    			}
    			#box .item{
    				/* 浮动布局 */
    				float: left;
    				width: 290px;
    				/* background-color: purple; */
    				margin-left: 10px;
    			}
    			#box .clear_float{
    				/* background-color: palevioletred;
    				height: 50px; */
    				/* 清除浮动 */
    				clear: both;
    			}
    			.item_list{
    				/* 有一个具体的宽度 再去auto  浏览器才会根据自身的宽度 与该元素的宽度
    				 进行自适应距离的*/
    				width: 1200px;
    				margin: 0 auto;
    				/* background-color: plum; */
    			}
    			/* item中的布局 */
    			.item img{
    				/* 跟父标签等宽 */
    				width: 100%;
    			}
    			.item h4{
    				margin: 10px 0;
    				font-size: 20px;
    			}
    			.item .detail{
    				margin-bottom: 10px;
    				color: rosybrown;
    				font-size: 17px;
    			}
    			.item .click_num{
    				color: blue;
    				font-size: 12px;
    			}
    		</style>
    	</head>
    	<body>
    		<div id="box">
    			<h3>热播</h3>
    			<div class="item_list">
    				<div class="item">
    					<img src="../img/img1.png" />
    					<h4>太阳的后裔</h4>
    					<p class="detail">宋仲基欧巴</p>
    					<p class="click_num">点击次数:23456567次</p>
    				</div>
    				<div class="item">
    					<img src="../img/img2.png" />
    					<h4>太阳的后裔</h4>
    					<p class="detail">宋仲基欧巴</p>
    					<p class="click_num">点击次数:23456567次</p>
    				</div>
    				<div class="item">
    					<img src="../img/img3.png" />
    					<h4>太阳的后裔</h4>
    					<p class="detail">宋仲基欧巴</p>
    					<p class="click_num">点击次数:23456567次</p>
    				</div>
    				<div class="item">
    					<img src="../img/img4.png" />
    					<h4>太阳的后裔</h4>
    					<p class="detail">宋仲基欧巴</p>
    					<p class="click_num">点击次数:23456567次</p>
    				</div>
    				<div class="clear_float"></div>
    			</div>
    		</div>
    	</body>
    </html>
    

     

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值