我想在一个html 上面生成好多小方块

我想在一个html 上面生成好多小方块,结果与百度图片那种相似,方块大小是相同的,

(1) 实现的方法 就是设置 div 的float 属性就可以了 left

div { background-color:Gray; width:150px; height:150px;  float:left; margin:10px;}

(2)怎么让div 的文字显示在div 的中央

text-align:center; line-height:150px;text-align:center;(水平居中)line-height:和高一样的参数;(垂直居中),

(3)怎么让div 显示在页面的特定部位

<div  style='position:absolute;top:20%;left:15%;z-index:9; width:800px; height:600px'></div>

(4) 使用jiathis 分享

<script type="text/javascript" src="http://v3.jiathis.com/code/jiathis_r.js?uid=1356925732494226&move=0" charset="utf-8"></script>

将这句话加入到body 里面就行了

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
<style type="text/css" >
.group1 { background-color:Gray; width:150px; height:150px; float:left; margin:10px; text-align:center; line-height:150px;}
.group2 { background-color:Gray; width:80px; height:80px; margin-left:0px; margin-right:10px; margin-bottom:10px; margin-top:10px; text-align:center;line-height:80px; }
.group3 { background-color:Gray; width:80px; height:80px; float:left; margin-right:10px; text-align:center;line-height:80px; }
</style>
<!-- JiaThis Button BEGIN -->
<script type="text/javascript" src="http://v3.jiathis.com/code/jiathis_r.js?uid=1356925732494226&move=0" charset="utf-8"></script>
<!-- JiaThis Button END -->

</head>
<body>
<div id="leftbar" style='position:absolute;top:20%;z-index:9; margin:0px; width:100px; height:600px'>
<div class="group2">2</div>
<div class="group2">2</div>
<div class="group2">2</div>
<div class="group2">2</div>
<div class="group2">2</div>
</div>
<div id="topbar" style=" position:absolute; top:0%; margin-left:200px; width:800px; height:100px" >
<div class="group3">3</div>
<div class="group3">3</div>
<div class="group3">3</div>
<div class="group3">3</div>
<div class="group3">3</div>
</div>
<div style='position:absolute;top:20%;left:15%;z-index:9; width:800px; height:600px'>
<div class="group1">1</div>
<div class="group1">1</div>
<div class="group1">1</div>
<div class="group1">1</div>
<div class="group1">1</div>
<div class="group1">1</div>
<div class="group1">1</div>
<div class="group1">1</div>
<div class="group1">1</div>
<div class="group1">1</div>
<div class="group1">1</div>
</div>
<script type="text/javascript" src="http://v3.jiathis.com/code/jiathis_r.js?uid=1356925732494226&move=0" charset="utf-8"></script>
</body>
</html>

转载于:https://www.cnblogs.com/gisbeginner/archive/2013/01/07/2849423.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值