html使用display:inline-block实现标签右对齐,值左对齐效果。和设置div宽度,并居中显示。嵌套div的里层div文字居中显示

5 篇文章 0 订阅

要实现下图所示的效果:


代码:

<!DOCTYPE html>
<html>
<head>
<script src="/jquery/jquery-1.11.1.min.js">
</script>
<script>
$(document).ready(function(){
  $("p").click(function(){
    $(this).hide();
  });
});
</script>
</head>
<body>
<div style="display:inline-block; float:left;width:50% ;background-color:blue">
<label style="width:50%; float:left;text-align:right;background-color:red;">key1rrr</label>
<span style="">value1</span>
</div>
<div style="float:left;width:100%;margin-top:5px"><span >22</span></div>
<div style="display:inline-block; float:left;width:50% ;background-color:blue">
<label style="width:50%; float:left;text-align:right;background-color:red;">key1rrrrrr</label>
<span style="">value1gggg</span>
</div>

<div style="display:inline-block; float:left;width:50% ;background-color:blue">
<label style="width:50%; float:left;text-align:right;background-color:red;">key1rrrfff</label>
<span style="">valufffe1</span>
</div>
<div style="display:inline-block; float:left;width:50% ;background-color:blue">
<label style="width:50%; float:left;text-align:right;background-color:red;">key1rrr</label>
<span style="">value1</span>
</div>
</body>
</html>

可直接把代码拿到w3c网站测试



2,设置div宽度,并居中显示

<html>
<head>
<style type="text/css">

</style>
</head>

<body>
<div style="display:inline-black;float:left;width:100%;text-align:center">
     <div style="width:600px;"><span style="background-color:red;"> div 元素的内容不会显示出来!</span></div>
</div>
</body>
</html>


显示结果:



总结:使用标签前要了解此标签的属性有哪些,比如span标签没有width属性,所以即使设置了宽度也不会起作用,这是小编经常犯的错误。


3,嵌套div的里层div文字居中显示

<div align="center" style="display:inline-black; float:left; margin-top:50px;width:100%;text-align:center">
		<span style="width:100%;float:left;">
			<font size="4"  color="#337ab7"><strong>报告解说</strong></font></span>
		</span>
		<br/>
		<br/>
		<div style="width:850px;margin:0 auto;text-align:left" >
			<font size="2"  color="#337ab7"><strong>对于报告中出现的部分英文码解释如下:<br/>
			(1) 规则类型码 : “CRS”表示“跨机构申请类规则”; “GRP”表示“团伙欺诈类规则”; “HIS”表示“历史申请类规则”; “BLK”表示“黑名单类规则”; “LGC”表示“当前申请自身逻辑判断类规则。
			<br/>(2) 规则威胁等级: “H”表示“high,建议拒绝该申请”; “M”表示“medium,建议人工审核”; “L”表示“low,建议通过该申请”。
			</strong></font>
		
		</div>
	</div>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

老马识途2.0

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值